How can I start android application info screen programmatically?
Asked Answered
D

6

64

Is it possible to start the "application info" screen (that is, MenuSettingsApplicationsManage Applications → select any application) from another app?

Disturbing answered 12/12, 2010 at 12:6 Comment(1)
Is there a way to open specific app's DATA USAGE details info?Merimerida
A
84

In 2.2 and below, there is no public APIs you can access. But you can still start the InstalledAppDetails activity just as the ManageApplications does. see here

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

Conclusion: you can start the "application info" screen like this i wrote:

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);
}
Aerator answered 23/1, 2011 at 5:29 Comment(5)
thank you so much! this saved me a lot of time. should the comment "above 2.3" be changed to "2.3 and above"?Keeper
this works perfectly for any installed application. However if i try to open settings of any system application, a blank screen comes up.Rockaway
Also we need to add intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); in both statements. i.e. if(){...here...} else {...here...}Darton
Awesome Man!! +100 \m/Mats
Yes, it's Working .awesome !!Railway
Q
77

From API Level 9 (Android 2.3) you can start an Intent with android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS. Thus:

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

}
Queue answered 18/9, 2013 at 13:41 Comment(0)
H
20

I used Paolo solution in order to open the Application Details Settings in SDK 23+ when the user turned down the permission request in the past and choose the "Don't ask again" option in the permission request system dialog.

But in this case I used the getPackageName() method directly.

Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + getPackageName()));
startActivity(intent);
Hauteloire answered 23/10, 2015 at 8:51 Comment(0)
A
17

Old question, improved answer:

/**
 * <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;
}
Aultman answered 3/7, 2014 at 5:32 Comment(0)
M
8

In Android 2.3, you can use startActivity() on an ACTION_APPLICATION_DETAILS_SETTINGS Intent, with a proper Uri, to bring up your app's "manage" screen. However, this is new to Android 2.3 -- I am not aware of a way to do that in previous versions of Android.

Maxma answered 12/12, 2010 at 12:34 Comment(0)
O
6
startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_SETTINGS));

will bring you to the settings / application list. If you want to open one specific application, I think in 2.2 and below there's no way, so you'd need to go a (not necessarily suggested, because inofficial) way:

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

But note that this is not recommended because it's not an official API / intent (filter) and might therefore change in the future.

Odel answered 12/12, 2010 at 12:41 Comment(2)
I won't recommend the latter. What if a malicious app uses the package: com.android.settings?Queue
@PaoloRovelli I wrote "not necessarily recommended", but for a different reason. I don't think you can avoid the danger that you mention; if two apps use the same intent (string), then the user will always get a dialog to choose the app to use (which lowers the risk a bit). But also, note that the parameter in the first approach is also nothing else but a string: developer.android.com/reference/android/provider/… - so that's no protection from a malicious app either if it uses the com.android.settings package name.Odel

© 2022 - 2024 — McMap. All rights reserved.