Search
 
SCRIPT & CODE EXAMPLE
 

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!");
    }
Comment

PREVIOUS NEXT
Code Example
Java :: Java Catching base and child exception classes 
Java :: java coding standards for constants 
Java :: subtract two variables in java 
Java :: TestNG Data Provider 
Java :: sibling search java program 
Java :: convert from java to kotlin online 
Java :: how to clear the consol after input java 
Java :: java naming convention acronyms 
Java :: error message pushes button down 
Java :: get string match percentage java 
Java :: how to not allow a user to enter a mark greater than 100 or below 0 in java 
Java :: last resultset method 
Java :: What are the design patterns involved in JDBC architecture? 
Java :: efficient generic duplicate finding class java 
Java :: print map in java log 
Java :: java.lang.number is interface or abstract class 
Java :: java instanciar objeto File 
Java :: @Controller 
Java :: Copying Arrays Using Assignment Operator Java 
Java :: java.lang.nullpointerexception (no error message) 
Java :: java no name array eg 
Java :: java for loop example 
Java :: java private access modifier 
Java :: java skip foreach 
Java :: like clause with param in spring jpa 
Java :: jks not found when trying googlenethttptransport 
Java :: How To Export Records From JTable To MS Excel 
Java :: java class extension 
Java :: dependency maven mvn assertj asserting testing framework 
Java :: jdbc code 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =