Code example for PackageManager

Methods: getLaunchIntentForPackagesleep

0
    private Collection<ProcessErrorStateInfo> launchActivity(String packageName) {
        Intent homeIntent = new Intent(Intent.ACTION_MAIN);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
        Intent intent = mPackageManager.getLaunchIntentForPackage(packageName);
 
        // We check for any Crash or ANR dialogs that are already up, and we ignore them.  This is 
        // so that we don't report crashes that were caused by prior apps (which those particular 
        // tests should have caught and reported already).  Otherwise, test failures would cascade 
        // from the initial broken app to many/all of the tests following that app's launch. 
        final Collection<ProcessErrorStateInfo> preErr = mActivityManager.getProcessesInErrorState();
 
        // Launch Activity 
        mContext.startActivity(intent);
 
        try { 
            Thread.sleep(mAppLaunchTimeout);
        } catch (InterruptedException e) {
            // ignore 
        } 
 
        // Send the "home" intent and wait 2 seconds for us to get there 
        mContext.startActivity(homeIntent);
        try { 
            Thread.sleep(mWorkspaceLaunchTimeout);
        } catch (InterruptedException e) {
            // ignore 
        } 
 
        // See if there are any errors.  We wait until down here to give ANRs as much time as 
Stop searching for code, let great code find you!  Add Codota to your java IDE