java - how to reload main activity after click "OK" on AlertDialog -


I have an alert dialog and I have to reload the main activity after clicking "OK". The problem is that after my activity has returned to the home screen, click OK

Java Code:.

  private void buildAlertMessageNoGps () {final AlertDialog.Builder builder = new AlertDialog.Builder (this); builder.setMessage ( "This application needs GPS satellites or wireless networks enable localization" + "\ n" + "Do you want to enable it?") .setCancelable (right) .setPositiveButton ( "Yes", the new DialogInterface.OnClickListener () {public void onClick (last DialogInterface dialog, @SuppressWarnings ( "unused") final int id) {StartActivity (new intent (Settings.ACTION_LOCATION_SOURCE_SETTINGS)); end (); startActivity (getIntent ());}}) .setNegativeButton ("No", New DialogInterface.OnClickListener () {Public Zero onClick (Last DialogInterface Dialog, @SuppressWarnings ("Unused") Last Flood Nank id) {dialog.cancel ();}}); Final Alert Dealog Warning = Builder.Create (); Alert.show ();   

Help will be appreciated.

Change the code

  new DialogInterface.OnClickListener () {public void onClick (last DialogInterface dialog, @SuppressWarnings ( "unused") final int id) {startActivity (new intent (Settings.ACTION_LOCATION_SOURCE_SETTINGS)); End(); StartActivity (getIntent ()); }   

the

  new DialogInterface.OnClickListener () {public void onClick (Last DialogInterface dialog, @SuppressWarnings ( "unused") final int id) { StartActivityForResult (new intent (settings. ACTION_LOCATION_SOURCE_SETTINGS), 0); }    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -