Example usage for android.app Instrumentation startActivitySync

List of usage examples for android.app Instrumentation startActivitySync

Introduction

In this page you can find the example usage for android.app Instrumentation startActivitySync.

Prototype

public Activity startActivitySync(Intent intent) 

Source Link

Document

Start a new activity and wait for it to begin running before returning.

Usage

From source file:love.juhe.androidmonkey.MonkeyActivityEvent.java

@SuppressLint("NewApi")
@Override//from   w w  w  .  j  a v a  2  s.com
public int fireEvent(Instrumentation testRuner) {
    Intent intent = getEvent();
    MonkeyLog.l(":Switch: " + intent.toUri(0));

    if (mAlarmTime != 0) {
        Bundle args = new Bundle();
        args.putLong("alarmTime", mAlarmTime);
        intent.putExtras(args);
    }
    try {
        //         IntentFilter filter = new IntentFilter(getEvent().getAction());
        //         ActivityMonitor monitor = testRuner.addMonitor(filter, null, true);
        testRuner.startActivitySync(intent);
        //         testRuner.waitForMonitorWithTimeout(monitor, 10);

    } catch (SecurityException e) {
        MonkeyLog.l("** Permissions error starting activity " + intent.toUri(0));
        return MonkeyEvent.INJECT_ERROR_SECURITY_EXCEPTION;
    }
    return MonkeyEvent.INJECT_SUCCESS;
}