Open AndroidDeveloperLB opened 6 years ago
When this code was implemented, Kotlin was not supported by Android Studio. I did not test the snippet you send, but I don't doubt that it really works. I am just not going to change the method in the codebase to avoid mixing Kotlin and java in the same project, so people don't get confused with mixed languages.
You can easily convert it to Java. Here:
public static boolean isNotificationServiceEnabled(Context context ){
return NotificationManagerCompat.getEnabledListenerPackages(context).contains(context.getPackageName());
}
If you could make the changes and send a pull request I will be glad to test and accept it if everything runs fine.
It's an official API , which was available for a long time: https://developer.android.com/reference/android/support/v4/app/NotificationManagerCompat#getenabledlistenerpackages
OK here: https://github.com/Chagall/notification-listener-service-example/pull/7
I also updated various other stuff, to match what we use today, and handled some warnings that the IDE and Lint showed. I could even convert to Kotlin, but I didn't want to :)
What do you mean " without user interaction" ? And why do you ask this here? It has nothing to do with the topic . Please ask in a normal, new thread.
@Chagall Did you check it out?
Went afk from this account for a long time, will check this as soon as I can. Better late than never.
It's much easier to use this code instead:
Much better than this:
https://github.com/Chagall/notification-listener-service-example/blob/master/app/src/main/java/com/github/chagall/notificationlistenerexample/MainActivity.java