Get intent filter for receivers

前端 未结 1 480
梦毁少年i
梦毁少年i 2020-12-31 11:18

I am trying to get a list of receivers that handle android.intent.action.BOOT_COMPLETED for other applications.

I can get only the apps with that action

相关标签:
1条回答
  • 2020-12-31 11:37

    I reformatted for people. Use this and thanks for question.

    PackageManager packageManager = getPackageManager();
    List<String> startupApps = new ArrayList<String>();
    Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED);
    List<ResolveInfo> activities = packageManager.queryBroadcastReceivers(intent, 0);
    for (ResolveInfo resolveInfo : activities) {
        ActivityInfo activityInfo = resolveInfo.activityInfo;
        if (activityInfo != null) {
            startupApps.add(activityInfo.name);
        }
    }
    
    0 讨论(0)
提交回复
热议问题