我怎样才能以编程方式启动android应用程序信息屏幕?

是否可以从另一个应用程序启动“应用程序信息”屏幕(即, MenuSettingsApplicationsManage Applications →select任何应用程序)?

在2.2及更低版本中,没有可以访问的公共API。 但是,您仍然可以像pipe理应用程序一样启动InstalledAppDetails活动。 看到这里

  // utility method used to start sub activity private void startApplicationDetailsActivity() { // Create intent to start new activity Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, InstalledAppDetails.class); intent.putExtra(APP_PKG_NAME, mCurrentPkgName); // start new activity to display extended information startActivityForResult(intent, INSTALLED_APP_DETAILS); } 

结论 :你可以像这样开始“应用程序信息”屏幕,我写道:

 private static final String SCHEME = "package"; private static final String APP_PKG_NAME_21 = "com.android.settings.ApplicationPkgName"; private static final String APP_PKG_NAME_22 = "pkg"; private static final String APP_DETAILS_PACKAGE_NAME = "com.android.settings"; private static final String APP_DETAILS_CLASS_NAME = "com.android.settings.InstalledAppDetails"; public static void showInstalledAppDetails(Context context, String packageName) { Intent intent = new Intent(); final int apiLevel = Build.VERSION.SDK_INT; if (apiLevel >= 9) { // above 2.3 intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts(SCHEME, packageName, null); intent.setData(uri); } else { // below 2.3 final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22 : APP_PKG_NAME_21); intent.setAction(Intent.ACTION_VIEW); intent.setClassName(APP_DETAILS_PACKAGE_NAME, APP_DETAILS_CLASS_NAME); intent.putExtra(appPkgName, packageName); } context.startActivity(intent); } 

API Level 9 (Android 2.3)开始,您可以使用android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS启动一个Intent。 从而:

 packageName = "your.package.name.here" try { //Open the specific App Info page: Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + packageName)); startActivity(intent); } catch ( ActivityNotFoundException e ) { //e.printStackTrace(); //Open the generic Apps page: Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); startActivity(intent); } 

老问题,改进答案:

 /** * <p>Intent to show an applications details page in (Settings) com.android.settings</p> * * @param context The context associated to the application * @param packageName The package name of the application * @return the intent to open the application info screen. */ public static Intent newAppDetailsIntent(Context context, String packageName) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse("package:" + packageName)); return intent; } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra("pkg", packageName); return intent; } Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra("com.android.settings.ApplicationPkgName", packageName); return intent; } 

在Android 2.3中,您可以使用ACTION_APPLICATION_DETAILS_SETTINGS Intent上的startActivity()和适当的Uri来调出应用程序的“pipe理”屏幕。 然而,这是Android 2.3的新function – 我不知道在以前的Android版本中有这样做的方法。

我使用Paolo解决scheme来打开SDK 23+中的应用程序详细信息设置,当用户过去拒绝了权限请求,并在权限请求系统对话框中select“不要再请求”选项。

但在这种情况下,我直接使用getPackageName()方法。

 Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + getPackageName())); startActivity(intent); 
 startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_SETTINGS)); 

会带你到设置/应用程序列表。 如果你想打开一个特定的应用程序,我认为在2.2和以下是没有办法的,所以你需要去(不一定build议,因为非官方)的方式:

 final Intent i = new Intent("android.intent.action.VIEW"); i.setComponent(new ComponentName("com.android.settings","com.android.settings.InstalledAppDetails")); i.putExtra(...); // need to figure out the correct extra, probably app package name startActivity(i); 

但请注意,不build议这样做,因为它不是官方的API /意图(filter),因此可能会在将来更改。