How to Start Android Application Info Screen Programmatically

how i can start application info screen in android?

as per this link

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

or

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

Invoke Android application info screen

From api level 9 and above you should be able to achieve what you want with the following:

Intent i = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
i.setData(Uri.parse("package:" + packageName));
startActivity(i);

Where packageName is for example: com.example.myapp

Opening Android Settings programmatically

I used the code from the most upvoted answer:

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);

It opens the device settings in the same window, thus got the users of my android application (finnmglas/Launcher) for android stuck in there.

The answer for 2020 and beyond (in Kotlin):

startActivity(Intent(Settings.ACTION_SETTINGS))

It works in my app, should also be working in yours without any unwanted consequences.

How to open application android programmatically if i don't know package name

Maybe something like this would help, but I have to add that this is a terrible approach as app names can be the same for different apps, and some apps (like "Contacts") have different labels based on the language set

     /**
*
* @param appName The target app to launch, if there are multiple apps with same name, the first found will be launched
* @throws IllegalArgumentException If the target app was not found
*/
public void runApp(String appName) throws IllegalArgumentException {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
for ( ResolveInfo info : getPackageManager().queryIntentActivities( mainIntent, 0) ) {
if ( info.loadLabel(getPackageManager()).equals(appName) ) {
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(info.activityInfo.applicationInfo.packageName);
startActivity(launchIntent);
return;
}
}
throw new IllegalArgumentException("Application not found!");
}


Related Topics



Leave a reply



Submit