0

I want to know what code do I need to write to return a set of apps that are not system apps.

    public static List<?> getInstalledApplication(Context c) {
    return c.getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);

}

This is the code for the method which returns everything. I want to show only apps that are user launch able. How can I do that?

m4tx
  • 4,139
  • 5
  • 37
  • 61
vishalmullur
  • 1,094
  • 4
  • 14
  • 32

1 Answers1

1

Check out the comment from @Wand Maker for this question: How to get installed applications in Android and no system apps?

I think you need to use PackageManager to find out all the apps that support intent-filter with action "android.intent.action.MAIN" and category "android.intent.category.LAUNCHER" – Wand Maker Jul 6 at 15:23

You can do this by using PackageManager.queryIntentActivities (http://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentActivities(android.content.Intent, int))

E.g.

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
Community
  • 1
  • 1
  • I have tried it but it still doesnt help. Could you exactly tell how to write it according to the above code please? – vishalmullur Jul 11 '13 at 18:30
  • It gives me error about getPackageManager() and also what should I return in place of c? – vishalmullur Jul 11 '13 at 18:32
  • I added an example. how to call it getPackageManager() is a method in context (http://developer.android.com/reference/android/content/Context.html#getPackageManager()) so you can e.g. call it from an activity –  Jul 11 '13 at 18:45
  • When I write that the class extends activity it the tell me to remove the static reference from this method and is I do that then the place where I call this method there it gives error saying I should change it back to static – vishalmullur Jul 11 '13 at 18:49
  • These are really basic Java issues you are facing. Just don't make your method static. I strongly suggest brushing up on java/android dev basics before trying to jump into the deep end of the pool –  Jul 11 '13 at 20:03
  • Thanks but I feel I know my way around both Java and Android. The problem is this is something I havent seen before so I asked for code specific to this. Thanks – vishalmullur Jul 12 '13 at 16:28