Search code examples
androideventsmobilenotificationsdetect

Android App Detect Other Activity


I've been trying to look up solution but I just can't seem to find one that suits my need. It could be that I'm not using the correct keyword, so I'm gonna try to explain it the best I can.

Simply saying, I'm building an Android application. The application need to detect some other activities on the phone and show some message.

For example:

  1. User launch MyApplication.

  2. User received some notification from another app. (a phone call, text message, email, whatever)

  3. MyApplication shows a message via toast or dialog, saying that "you just received an notification from another app"

I'm not entirely sure what function I should be looking for here, any help is appreciated.

Thanks!


Solution

  • You will want to look at NotificationListenerService, this will let you receive calls from the system when new notifications are posted or removed, or their ranking changed.

    Once you receive a callback from the NotificationListenerService, you will want to create a Toast.

    Take a look at this tutorial should help you get started.