Java Code Examples for android.app.Instrumentation#checkStartActivityResult()

The following examples show how to use android.app.Instrumentation#checkStartActivityResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Ask that a new activity be started for voice interaction.  This will create a
 * new dedicated task in the activity manager for this voice interaction session;
 * this means that {@link Intent#FLAG_ACTIVITY_NEW_TASK Intent.FLAG_ACTIVITY_NEW_TASK}
 * will be set for you to make it a new task.
 *
 * <p>The newly started activity will be displayed to the user in a special way, as
 * a layer under the voice interaction UI.</p>
 *
 * <p>As the voice activity runs, it can retrieve a {@link android.app.VoiceInteractor}
 * through which it can perform voice interactions through your session.  These requests
 * for voice interactions will appear as callbacks on {@link #onGetSupportedCommands},
 * {@link #onRequestConfirmation}, {@link #onRequestPickOption},
 * {@link #onRequestCompleteVoice}, {@link #onRequestAbortVoice},
 * or {@link #onRequestCommand}
 *
 * <p>You will receive a call to {@link #onTaskStarted} when the task starts up
 * and {@link #onTaskFinished} when the last activity has finished.
 *
 * @param intent The Intent to start this voice interaction.  The given Intent will
 * always have {@link Intent#CATEGORY_VOICE Intent.CATEGORY_VOICE} added to it, since
 * this is part of a voice interaction.
 */
public void startVoiceActivity(Intent intent) {
    if (mToken == null) {
        throw new IllegalStateException("Can't call before onCreate()");
    }
    try {
        intent.migrateExtraStreamToClipData();
        intent.prepareToLeaveProcess(mContext);
        int res = mSystemService.startVoiceActivity(mToken, intent,
                intent.resolveType(mContext.getContentResolver()));
        Instrumentation.checkStartActivityResult(res, intent);
    } catch (RemoteException e) {
    }
}
 
Example 2
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * <p>Ask that a new assistant activity be started.  This will create a new task in the
 * in activity manager: this means that
 * {@link Intent#FLAG_ACTIVITY_NEW_TASK Intent.FLAG_ACTIVITY_NEW_TASK}
 * will be set for you to make it a new task.</p>
 *
 * <p>The newly started activity will be displayed on top of other activities in the system
 * in a new layer that is not affected by multi-window mode.  Tasks started from this activity
 * will go into the normal activity layer and not this new layer.</p>
 *
 * <p>By default, the system will create a window for the UI for this session.  If you are using
 * an assistant activity instead, then you can disable the window creation by calling
 * {@link #setUiEnabled} in {@link #onPrepareShow(Bundle, int)}.</p>
 */
public void startAssistantActivity(Intent intent) {
    if (mToken == null) {
        throw new IllegalStateException("Can't call before onCreate()");
    }
    try {
        intent.migrateExtraStreamToClipData();
        intent.prepareToLeaveProcess(mContext);
        int res = mSystemService.startAssistantActivity(mToken, intent,
                intent.resolveType(mContext.getContentResolver()));
        Instrumentation.checkStartActivityResult(res, intent);
    } catch (RemoteException e) {
    }
}