I would like to be able to open an activity in the application when a push notification is received without any user action. Is it possible to do with onesignal or some other way to open the app automatically using a push?
Asked
Active
Viewed 951 times
2 Answers
0
you can try with this,hope this code will help you.
Intent restart = context.getPackageManager().
getLaunchIntentForPackage(context.getPackageName());
restart.addFlags(Intent.enter code here
FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(restart);

Daya Shankar
- 111
- 4
0
You can simply start your home activity inside FirebaseMessagingService.onMessageReceived
But if application is currently running you don't have to do that. You need kind of controller and check is application in foreground

Stanislav Bondar
- 6,056
- 2
- 34
- 46
-
Thanks for your answer, now I will check that, Really what I want to do would be the same as whatsapp for example when you receive a call, opens a screen to answer or refuse, is what I need to do, I'm on the right track or should Investigate something else? – Braian Ochoa Aug 30 '17 at 15:12
-
@BraianOchoa If you need user action (answer or refuse) you have to start activity without care of application lifecycle. – Stanislav Bondar Aug 31 '17 at 08:37