Performing stop of activity that is not resumed
That doesn't seem right to me. The splash activity would now be the top activity in the stack, so the
HomeActivity
onStop lifecycle method would get called eventually. Coincidentally, I moved the startActivity
call for the splash activity from onCreate
to onResume
in the HomeActivity
, and the error goes away.
gps.showSettingsAlert();//inside this use startActivityForResult(new Intent().setClass(this, MainActivity.class), result_code);
Edit: your method should be in MainActivity.class not in Service as service don't have ui so no point of getting the result there.
-
public void showSettingsAlert(Context context){
-
AlertDialog.Builder alertdialog = new AlertDialog.Builder(context);
-
alertdialog.setTitle("Oups ! pas de données GPS");
-
alertdialog.setMessage("GPS n'est pas activé sur votre appareil, voulez vous l'activer ?");
-
-
/*
-
handling the buttons :
-
*/
-
alertdialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
-
-
-
public void onClick(DialogInterface dialog,int which) {
-
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
-
startActivityForResult(intent, RESULT_CODE_GPS);
-
-
-
}
-
});
-
-
// on pressing cancel button
-
alertdialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
-
public void onClick(DialogInterface dialog, int which) {
-
dialog.cancel();
-
}
-
});
-
-
alertdialog.show();
-
-
}
参考:http://stackoverflow.com/questions/25867085/refreshing-activity-performing-stop-of-activity-that-is-not-resumed-error
http://stackoverflow.com/questions/21947675/android-4-4-2-java-lang-runtimeexception-performing-stop-of-activity-that-is
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/66586898
- 点赞
- 收藏
- 关注作者
评论(0)