0

I have an issue with the closing and restarting of my application. I have a widget on homescreen and also I created a shortcut for the app on homescreen. I am entering the app via shortcut and closing it in Activity B by pressing phone's home button. Now I launch the app via widget and pass through Activity A -> Activity B -> Activity C, then I come back to exit the app via phone's back button which goes like from Activity C -> Activity B -> Activity A. In Activity A, when I click back button it should close the app, but inspite of this it's showing the Activity B which is running in background that I launched by app shortcut.

I tried by killing the app in onPause(), it works fine. But then I have a Camera functionality, so as soon as I click a picture and click on save, it exits the app. I think on moving back to the activity from phone's Camera it goes into onPause() which is causing the app to exit.

Can anyone provide a solution for this. Thanks a lot.

Lavanya
  • 3,903
  • 6
  • 31
  • 57

1 Answers1

0

Instead of killing the app in onPause start the activity from shortcut or widget using intent flag :

FLAG_ACTIVITY_CLEAR_TOP or 
FLAG_ACTIVITY_CLEAR_TASK

Please refer : this

Gaurav Navgire
  • 780
  • 5
  • 17
  • 29