I am making a service which allows to automatically open an application which has notification message in the notification bar without touching in the app. For example, I have a message from Skype app and it shows in the notification bar. Normal way, the user have to click the notification message to go to the app. Instead of that, my service will auto listen the incoming notification, detect the app and open it from intent. Is it possible in Android? How could I achieve it? I am using Android 5.0 in Galaxy S4. Thank all
Asked
Active
Viewed 161 times
1
-
My android version is 5.0 . My phone is Samsung S4 – user3051460 Oct 20 '16 at 08:22
-
You can explicitly target to service instead of activity in intent. Then start your activity via service. But this way you shouldn't do that since you can do any jobs inside your activity when clicked on notification. – james Oct 20 '16 at 08:48
1 Answers
1
You need to use NotificationListenerService to listen for each notification NotificationListenerService has two methods
onNotificationPosted
Implement this method to learn about new notifications as they are posted by apps.onNotificationPosted
Implement this method to learn when notifications are removed.
in first method you have StatusBarNotification instance you can get package name there and open the app directly as explains in this

Community
- 1
- 1

Sahil Manchanda
- 9,812
- 4
- 39
- 89
-
Very useful. I got packet name and run the app based on the packet name. However, it looks open the app, instead of open the message of incoming user. For example, when you click on notification message in notification bar, you can directly see the message. How can I do it? – user3051460 Oct 20 '16 at 11:41