Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to catch Intent's Extras if the activity is already running?

I put a notification in the status bar with a PendingIntent (with Extras info) that points to my main app (main activity). When the user clicks the staus bar, the PendingIntent is fired and my app launches and I can read the Extras info in my onCreate() method. So far so good.

But if my app is already running, the PendingIntent simply causes the app to come to the foreground and it does not call any of my methods, so I can't read the content in Extras. What can I do?

Thanks!

like image 627
user277827 Avatar asked Jan 23 '23 11:01

user277827


1 Answers

It does call a method.

Check out OnNewIntent

like image 196
Prashast Avatar answered Feb 03 '23 07:02

Prashast