2

is it possible to open android app when I'll push notification to the mobile? I can't find anything about that, does anyone tried to do that? Is it even possible?

Best Regards, Mateusz

crotoan
  • 173
  • 1
  • 13

1 Answers1

1

GCM messages are delivered to a BroadcastReceiver. Your BroadcastReceiver can, technically, call startActivity() on the Context passed into onReceive(). And hence, technically, you can have a GCM message start an activity.

Whether this is a good idea is another matter entirely.

On the whole, users do not like unexpected interruptions. Users may get very irritated with you if you pop up your activity over top of the user's book, game, movie, or car navigation session. Some of these scenarios, particularly the last one, can have fairly unpleasant results.

A Notification is a more typical approach for alerting the user about something that arrived as a result of a GCM message.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thank you for your Answer, it is what I expected. I know that it might me very irritated, but people who'll be using this APP will know that. If it would be possible to do in background it would be great too, but I don't think so it's possible... I have to send some picture and set it as wallpaper. Of course I would like to do that in background, but if it's even possible? Thank you! – crotoan Mar 20 '15 at 07:50
  • @MateuszKasprzak: I have not played with the APIs for changing wallpaper, sorry. – CommonsWare Mar 20 '15 at 11:12
  • Actually it doesn't matter if it's API for wallpaper, or sth else. Thank you for your help! :) – crotoan Mar 20 '15 at 12:20
  • @MateuszKasprzak: Well, a `BroadcastReceiver` is intrinsically in the background from a UI standpoint. You do not want to do much in `onReceive()`, as that is called on the main application thread, so if you are doing I/O, delegate that work to an `IntentService`. – CommonsWare Mar 20 '15 at 12:23