Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
113 views
in Technique[技术] by (71.8m points)

java - Android Service queryIntentService returns empty list

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>
question from:https://stackoverflow.com/questions/65642045/android-service-queryintentservice-returns-empty-list

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...