0

I want to notify the user of my app when he receives special news (from my app). How can i display some kind of a messeage to the user, even if my app is running in the background (or not running at all if possible).

I want him to be notified by text, and sound.

Thanks.

Michael A
  • 5,770
  • 16
  • 75
  • 127

3 Answers3

3

You need to write a service for doing this. Then in your service code use Notification class to show text and sound alerts.

Hakan Serce
  • 11,198
  • 3
  • 29
  • 48
1

Use Broadcast Receiver, to notify abt some action. Like updates, sms, or abt indicate when booting of a phone completes,etc... BroadCast Receiver works on the principle of Publisher and Subscriber pattern.

Kumar Vivek Mitra
  • 33,294
  • 6
  • 48
  • 75
1

If your app is not running and you want to do something you'll need some kind of broadcast receiver to receive a trigger. Probably what you'll end up doing is starting up at device boot, to schedule some stuff. This answer here should get you into the right direction

After that, the best way to notify the user is with notifications (or Toast messages if you're a great fan;)) Have a look at Status Bar Notifications

Community
  • 1
  • 1
vanleeuwenbram
  • 1,289
  • 11
  • 19