首页 > 代码库 > android 抓取手机应用包名和类名

android 抓取手机应用包名和类名

        ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        final PackageManager packageManager = getPackageManager();
        List<ResolveInfo> apps = packageManager.queryIntentActivities(
                mainIntent, 0);
        for (int i = 0; i < apps.size(); i++) {
            ResolveInfo info = apps.get(i);
            Log.e("TAG", info.activityInfo.loadLabel(packageManager)
                    + " pkgName "
                    + info.activityInfo.applicationInfo.packageName + " className "
                    + info.activityInfo.name);
        }

android 抓取手机应用包名和类名