我如何在Android中启动应用程序信息屏幕?

时间:2012-06-22 13:27:39

标签: java android

我想以编程方式开始管理应用程序(Settings -> Application -> manage application -> Application info)屏幕。我无法做到。有人可以帮帮我吗?

提前致谢。

2 个答案:

答案 0 :(得分:4)

API级别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);

}

答案 1 :(得分:3)

根据此link

在Android 2.3中,您可以在ACTION_APPLICATION_DETAILS_SETTINGS Intent上使用startActivity(),使用正确的Uri,以调出应用的“管理”屏幕

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);
}