Reputation: 3
Is it possible to start a Android Activity or App, when a push notification is received using a Service?
This only starts a new Activity, when the App is already running...
This is called in a Service when a push notification is received.
Intent in = new Intent(this, MainActivity.class);
in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(in);
Upvotes: 0
Views: 54
Reputation: 25863
Not possible (but possible, see my edit below).
Even if it was possible, do you think it is a good idea that an activity suddenly pops up out of nowhere and replaces anything you were doing? I would surely uninstall this app right away and give it the worst possible rating.
I suggest you show a notification instead.
After thinking about it, it is possible. You can launch any activity using am start -n
through the shell, however I strongly discourage you from doing so. The standard method is showing a notification.
Upvotes: 3