How To Kill Activity Or Call Finish() From Dialog?
I have the following code: public void promptUserToSaveModifications() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string
Solution 1:
You need the activity context to finish an activity. try
getApplicationContext().finish();
or
this.finish();
if you want to finish activity from an alert dialog in fragment the use
getActivity().finish();
Solution 2:
Always use YourActivity.this.finish()
in async method.
Solution 3:
You are using the dialog i.e you need to get the activity first to finish it. Use the following to finish your activity.
getActivity().finish();
Post a Comment for "How To Kill Activity Or Call Finish() From Dialog?"