2

I am thinking to show in a custom list view all app that can send notification (ie Facebook, Twitter, Games, etc..). I am using PackageManager to get all app installed, and I am thinking to use intent "filter":

    mContext = context;
    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    
    pm = mContext.getPackageManager();
    List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0);

CATEGORY_LAUNCHER includes a lot of apps that will never send notifications (settings, camera, live wallpaper). How can I fix it? Is its category the right way? Or I have to check all instlled apps permission and select only apps with "notification permission"? If yes what is that permission?

peterh
  • 11,875
  • 18
  • 85
  • 108
Marco Rossini
  • 469
  • 2
  • 6
  • 19
  • There is no permission or intent for notifications. As far as I know what your are trying to do is impossible. – Xaver Kapeller Apr 19 '14 at 16:24
  • What does "send notification" mean? Do you mean "display a `Notification`"? – CommonsWare Apr 19 '14 at 16:37
  • @CommonsWare Yeah, i mean display. – Marco Rossini Apr 19 '14 at 16:49
  • @XaverKapeller I'm afraid that u are right. So i can give at user the whole list (if an ipotetich "Extended List" option is checked) of installed apps and give him a set of option where he can restrict, at least, the list. For Example "Only mail" option checked will force CATEGORY_APPS_EMAIL as intent. I'm sorry again for my english :( i do my best. – Marco Rossini Apr 19 '14 at 16:54
  • If you are asking me if that's possible than yes. You can filter out apps which react to specific intents. – Xaver Kapeller Apr 19 '14 at 16:56
  • Ok, so i've to laern more about CATEGORY flags. Many Thanks. – Marco Rossini Apr 19 '14 at 17:08
  • @XaverKapeller I'm sorry again but i've another issue and i dont wanna open another post for similar argument. Cit from documentation: "Add a new category to the intent. Categories provide additional detail about the action the intent performs. When resolving an intent, only activities that provide all of the requested categories will be used." So how can i list XX number of categories with "or" and not the "and" proprety? – Marco Rossini Apr 21 '14 at 18:02
  • 1
    Does this answer your question? [How to get list of ALL apps (including System Apps)?](https://stackoverflow.com/questions/23599550/how-to-get-list-of-all-apps-including-system-apps) (since all apps can send notifications) – Ryan M Feb 17 '21 at 23:08

1 Answers1

-1

You can read the permissions used by the applications using

getPackageManager().getInstalledPackages(PackageManager.GET_PERMISSIONS);

and then you can filter the apps by checking if the application uses the permissions required for sending notification

Monika
  • 135
  • 1
  • 12