public void open(){
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setMessage(getApplicationContext().getResources().getString(R.string.searchFilterLocationMessage));
alertDialogBuilder.setPositiveButton(R.string.Ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
/*Intent intent = new Intent(Settings.ACTION_SETTINGS) ;
this.startActivity(intent);
*/
startActivityForResult(new Intent(Settings.ACTION_SETTINGS), 0);
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0) {
Intent intent = getIntent();
finish();
startActivity(intent);
}
}//onActivityResult
Launch the setting intent:
startActivity(new Intent(Settings.ACTION_SETTINGS));
and fetch the current Activity in onResume()
method:
public void onResume(){
super.onResume();
// Do your work
}
After getting back from the setting screen, your onResume()
method will be call and here you can fetch your location.