activity-finish

Finish all activities at a time

非 Y 不嫁゛ 提交于 2019-11-26 04:17:15
I have an application with multiple pages i.e., multiple activities and some of them remain open. Is there a way to close all activities at once? letsnurture Whenever you wish to exit all open activities, you should press a button which loads the first Activity that runs when your application starts then clear all the other activities, then have the last remaining activity finish. to do so apply the following code in ur project Intent intent = new Intent(getApplicationContext(), FirstActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("EXIT", true); startActivity

How to show a dialog to confirm that the user wishes to exit an Android Activity?

寵の児 提交于 2019-11-26 02:39:38
问题 I\'ve been trying to show a \"Do you want to exit?\" type of dialog when the user attempts to exit an Activity. However I can\'t find the appropriate API hooks. Activity.onUserLeaveHint() initially looked promising, but I can\'t find a way to stop the Activity from finishing. 回答1: In Android 2.0+ this would look like: @Override public void onBackPressed() { new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle("Closing Activity") .setMessage("Are you sure you

Finish all activities at a time

筅森魡賤 提交于 2019-11-26 01:15:42
问题 I have an application with multiple pages i.e., multiple activities and some of them remain open. Is there a way to close all activities at once? 回答1: Whenever you wish to exit all open activities, you should press a button which loads the first Activity that runs when your application starts then clear all the other activities, then have the last remaining activity finish. to do so apply the following code in ur project Intent intent = new Intent(getApplicationContext(), FirstActivity.class)

How to check if activity is in foreground or in visible background?

纵饮孤独 提交于 2019-11-26 00:47:15
I have a splash screen on a timer. My problem is that before I finish() my activity I need to check that the next activity has started because a system dialogue box pops-up and I only want to finish() ; once the user has selected an option from the dialogue box? I know that there are many questions on how to see if your activity is in the foreground but I do not know if this allows for dialogue boxes on top of the activity too. Here is the problem, the red is my activity which is in the background while the dialogue is in the foreground: EDIT: I have tried just not using finish() but then my