android.app.Instrumentation#checkStartActivityResult ( )源码实例Demo

下面列出了android.app.Instrumentation#checkStartActivityResult ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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) {
    }
}
 
/**
 * <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) {
    }
}