Reputation: 3647
I have a broadcast receiver for notification. My app is a webkit, and I want my app to be opened and directed to a certain URL when user clicks on the notification. Everything seems to be working fine, but I've encountered a problem now....
onNewIntent()
is called if the user last exited the app by pressing home button. but onNewIntent()
is not called if the user exited from back button. can anyone please help?
Upvotes: 2
Views: 2473
Reputation: 560
I solved it by using working handling the intent in the onNewIntent() and in the onResume()... if the app is coming in the onCreate() it probably doesn't have the data I need setup yet. Make sure you check for null to avoid NullPointerException.
Upvotes: 0
Reputation: 10063
The home button doesn't (usually) kill your application, it just gets taken off the screen. Any intents sent to it would be sent to onNewIntent()
.
The back button usually causes your activity to exit outright. Any intents sent to it would start it again from scratch via onCreate()
.
Note that in general, any time your application isn't on the screen, it can be killed by the system to conserve resources. This means that your application must always be prepared to restart itself from onCreate()
. Whatever you're doing in onNewIntent()
, you need to be able to handle it from onCreate()
as well.
Upvotes: 2