In my app,if i'm press back button or home up button it will closes my app. it's only when the activity is opened by the notification click ,so now i want to go to previous activity or home activity after a back press.
Asked
Active
Viewed 132 times
0
-
1Possible duplicate of [Disable back button in android](https://stackoverflow.com/questions/4779954/disable-back-button-in-android) – Ravindra Kushwaha Sep 21 '18 at 05:41
-
Accept the answer if it helps – Faiz Mir Sep 21 '18 at 06:51
2 Answers
1
Do this To Go Back
@Override
public void onBackPressed() {
Intent setIntent = new Intent(this,YOUR_CLASS.class);
startActivity(setIntent);
finish();
}

Faiz Mir
- 599
- 5
- 16
-
i know this my question is after notification clicked i launch activity b,if user back press it exits . – Vaithiya Nathan Sep 21 '18 at 07:38
0
Define this in your activity
@Override
public void onBackPressed() {
// Your Action over here.
}

Kanwarpreet Singh
- 2,037
- 1
- 13
- 28