Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

open application 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!");
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #open #application #programelly #android #studio
ADD COMMENT
Topic
Name
7+9 =