Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

系统存在多用户,很多应用无法遍历 #307

Open
Pateo-haifengchi opened this issue Dec 12, 2024 · 0 comments
Open

系统存在多用户,很多应用无法遍历 #307

Pateo-haifengchi opened this issue Dec 12, 2024 · 0 comments

Comments

@Pateo-haifengchi
Copy link

Android系统存在多用户时,很多应用无法遍历,提示no activities found to run,相关代码如下:
for (int i = 0; i < N; i++) {
Intent intent = new Intent(Intent.ACTION_MAIN);
String category = mMainCategories.get(i);
if (category.length() > 0) {
intent.addCategory(category);
}
List mainApps = APIAdapter.queryIntentActivities(packageManager, intent);

            if (mainApps == null || mainApps.size() == 0) {
                Logger.warningPrintln("// Warning: no activities found for category " + category);
                continue;
            }
            if (mVerbose >= 2) { // very verbose
                Logger.println("// Selecting main activities from category " + category);
            }
            final int NA = mainApps.size();
            for (int a = 0; a < NA; a++) {
                ResolveInfo r = mainApps.get(a);
                String packageName = r.activityInfo.applicationInfo.packageName;
                if (MonkeyUtils.getPackageFilter().checkEnteringPackage(packageName)) {
                    if (mVerbose >= 2) { // very verbose
                        Logger.println("//   + Using main activity " + r.activityInfo.name + " (from package "
                                + packageName + ")");
                    }
                    mMainApps.add(new ComponentName(packageName, r.activityInfo.name));
                } else {
                    if (mVerbose >= 2) { // very very verbose
                        Logger.println("//   - NOT USING main activity " + r.activityInfo.name
                                + " (from package " + packageName + ")");
                    }
                }
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant