Abra la aplicación Programelly Android Studio
/**
*
* @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!");
}
Mohamed Boumlyk