1

I'm trying to get app list using services. I'm using queryIntentActivities to get app list. I believe the problem is giving the wrong permissions from manifest but i couldn't figure it out. Does anyone have an idea on this ?

Thanks for any help!

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    PackageManager packageManager = getPackageManager();
    List<ResolveInfo> allApps = packageManager.queryIntentServices(intent, 0);
    for (ResolveInfo resolveInfo : allApps) {
        Log.d("Labels", (String) resolveInfo.loadLabel(packageManager));
    }


    return super.onStartCommand(intent, flags, startId);
}

and there is how i call this service from activity

    Intent intent = new Intent(getApplicationContext(),MyService.class);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    startService(intent);

here is the manifest file.

     <service android:name=".MyService"
         android:permission="android.permission.QUERY_ALL_PACKAGES">
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />

             <category android:name="android.intent.category.LAUNCHER" />

         </intent-filter>

     </service>

0 Answers0