FileDocCategorySizeDatePackage
MonkeyActivityEvent.javaAPI DocAndroid 1.5 API2296Wed May 06 22:41:08 BST 2009com.android.commands.monkey

MonkeyActivityEvent

public class MonkeyActivityEvent extends MonkeyEvent
monkey activity event

Fields Summary
private android.content.ComponentName
mApp
Constructors Summary
public MonkeyActivityEvent(android.content.ComponentName app)

        super(EVENT_TYPE_ACTIVITY);
        mApp = app;
    
Methods Summary
private android.content.IntentgetEvent()

return
Intent for the new activity

        
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setComponent(mApp);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);        
        return intent;
    
public intinjectEvent(android.view.IWindowManager iwm, android.app.IActivityManager iam, int verbose)

        Intent intent = getEvent();
        if (verbose > 0) {
            System.out.println(":Switch: " + intent.toURI());
        }
        try {
            iam.startActivity(null, intent, null, null, 0, null, null, 0,
                    false, false);
        } catch (RemoteException e) {
            System.err.println("** Failed talking with activity manager!");
            return MonkeyEvent.INJECT_ERROR_REMOTE_EXCEPTION;
        } catch (SecurityException e) {
            if (verbose > 0) {
                System.out.println("** Permissions error starting activity "
                        + intent.toURI());
            }
            return MonkeyEvent.INJECT_ERROR_SECURITY_EXCEPTION;
        }
        return MonkeyEvent.INJECT_SUCCESS;