//得到所有Activity public void getAllActivities(Context context){ try { //第一步:得到PackageName String packageName=context.getPackageName(); //第二步:得到PackageManager PackageManager packageManager=context.getPackageManager(); //第三步:得到PackageInfo PackageInfo packageInfo=packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); //第四步:得到ActivityInfo[] ActivityInfo[] activityInfoList = packageInfo.activities; //第五步:得到每一个Activity for (ActivityInfo activityInfo : activityInfoList) { System.out.println(""+activityInfo.name); } } catch (Exception e) { // TODO: handle exception } }
时间: 2024-10-13 23:24:01