android.app.VoiceInteractor Java Examples

The following examples show how to use android.app.VoiceInteractor. 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 5 votes vote down vote up
@Override
public IVoiceInteractorRequest startPickOption(String callingPackage,
        IVoiceInteractorCallback callback, VoiceInteractor.Prompt prompt,
        VoiceInteractor.PickOptionRequest.Option[] options, Bundle extras) {
    PickOptionRequest request = new PickOptionRequest(callingPackage,
            Binder.getCallingUid(), callback, VoiceInteractionSession.this,
            prompt, options, extras);
    addRequest(request);
    mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_START_PICK_OPTION,
            request));
    return request.mInterface;
}
 
Example #2
Source File: CameraFragment.java    From io2015-codelabs with Apache License 2.0 5 votes vote down vote up
private void startVoiceTrigger() {
    Log.d(TAG, "startVoiceTrigger: ");
    Option option = new Option("cheese", 1);
    option.addSynonym("ready");
    option.addSynonym("go");
    option.addSynonym("take it");
    option.addSynonym("ok");

    VoiceInteractor.Prompt prompt = new VoiceInteractor.Prompt("Say Cheese");
    getActivity().getVoiceInteractor()
        .submitRequest(new PickOptionRequest(prompt, new Option[]{option}, null) {
            @Override
            public void onPickOptionResult(boolean finished, Option[] selections, Bundle result) {
                if (finished && selections.length == 1) {
                    Message message = Message.obtain();
                    message.obj = result;
                    takePicture();
                } else {
                    getActivity().finish();
                    tearDown();
                }
            }
            @Override
            public void onCancel() {
                getActivity().finish();
                tearDown();
            }
        });
}
 
Example #3
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
    super.dump(prefix, fd, writer, args);
    writer.print(prefix); writer.print("mPrompt=");
    writer.println(mPrompt);
    if (mOptions != null) {
        writer.print(prefix); writer.println("Options:");
        for (int i=0; i<mOptions.length; i++) {
            VoiceInteractor.PickOptionRequest.Option op = mOptions[i];
            writer.print(prefix); writer.print("  #"); writer.print(i); writer.println(":");
            writer.print(prefix); writer.print("    mLabel=");
            writer.println(op.getLabel());
            writer.print(prefix); writer.print("    mIndex=");
            writer.println(op.getIndex());
            if (op.countSynonyms() > 0) {
                writer.print(prefix); writer.println("    Synonyms:");
                for (int j=0; j<op.countSynonyms(); j++) {
                    writer.print(prefix); writer.print("      #"); writer.print(j);
                    writer.print(": "); writer.println(op.getSynonymAt(j));
                }
            }
            if (op.getExtras() != null) {
                writer.print(prefix); writer.print("    mExtras=");
                writer.println(op.getExtras());
            }
        }
    }
}
 
Example #4
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void sendPickOptionResult(boolean finished,
        VoiceInteractor.PickOptionRequest.Option[] selections, Bundle result) {
    try {
        if (DEBUG) Log.d(TAG, "sendPickOptionResult: req=" + mInterface
                + " finished=" + finished + " selections=" + selections
                + " result=" + result);
        if (finished) {
            finishRequest();
        }
        mCallback.deliverPickOptionResult(mInterface, finished, selections, result);
    } catch (RemoteException e) {
    }
}
 
Example #5
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
PickOptionRequest(String packageName, int uid, IVoiceInteractorCallback callback,
        VoiceInteractionSession session, VoiceInteractor.Prompt prompt,
        VoiceInteractor.PickOptionRequest.Option[] options, Bundle extras) {
    super(packageName, uid, callback, session, extras);
    mPrompt = prompt;
    mOptions = options;
}
 
Example #6
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public IVoiceInteractorRequest startAbortVoice(String callingPackage,
        IVoiceInteractorCallback callback, VoiceInteractor.Prompt message, Bundle extras) {
    AbortVoiceRequest request = new AbortVoiceRequest(callingPackage,
            Binder.getCallingUid(), callback, VoiceInteractionSession.this,
            message, extras);
    addRequest(request);
    mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_START_ABORT_VOICE,
            request));
    return request.mInterface;
}
 
Example #7
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public IVoiceInteractorRequest startCompleteVoice(String callingPackage,
        IVoiceInteractorCallback callback, VoiceInteractor.Prompt message, Bundle extras) {
    CompleteVoiceRequest request = new CompleteVoiceRequest(callingPackage,
            Binder.getCallingUid(), callback, VoiceInteractionSession.this,
            message, extras);
    addRequest(request);
    mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_START_COMPLETE_VOICE,
            request));
    return request.mInterface;
}
 
Example #8
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public IVoiceInteractorRequest startConfirmation(String callingPackage,
        IVoiceInteractorCallback callback, VoiceInteractor.Prompt prompt, Bundle extras) {
    ConfirmationRequest request = new ConfirmationRequest(callingPackage,
            Binder.getCallingUid(), callback, VoiceInteractionSession.this,
            prompt, extras);
    addRequest(request);
    mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_START_CONFIRMATION,
            request));
    return request.mInterface;
}
 
Example #9
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
ConfirmationRequest(String packageName, int uid, IVoiceInteractorCallback callback,
        VoiceInteractionSession session, VoiceInteractor.Prompt prompt, Bundle extras) {
    super(packageName, uid, callback, session, extras);
    mPrompt = prompt;
}
 
Example #10
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Return the prompt informing the user of what they are picking, as per
 * {@link android.app.VoiceInteractor.PickOptionRequest VoiceInteractor.PickOptionRequest}.
 */
@Nullable
public VoiceInteractor.Prompt getVoicePrompt() {
    return mPrompt;
}
 
Example #11
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
CompleteVoiceRequest(String packageName, int uid, IVoiceInteractorCallback callback,
        VoiceInteractionSession session, VoiceInteractor.Prompt prompt, Bundle extras) {
    super(packageName, uid, callback, session, extras);
    mPrompt = prompt;
}
 
Example #12
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
AbortVoiceRequest(String packageName, int uid, IVoiceInteractorCallback callback,
        VoiceInteractionSession session, VoiceInteractor.Prompt prompt, Bundle extras) {
    super(packageName, uid, callback, session, extras);
    mPrompt = prompt;
}
 
Example #13
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Return the message informing the user of the problem, as per
 * {@link android.app.VoiceInteractor.AbortVoiceRequest VoiceInteractor.AbortVoiceRequest}.
 */
@Nullable
public VoiceInteractor.Prompt getVoicePrompt() {
    return mPrompt;
}
 
Example #14
Source File: BlueprintActivity.java    From CompositeAndroid with Apache License 2.0 4 votes vote down vote up
/**
 * Retrieve the active {@link VoiceInteractor} that the user is going through to
 * interact with this activity.
 */
@Override
public VoiceInteractor getVoiceInteractor() {
    return super.getVoiceInteractor();
}
 
Example #15
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Return the prompt informing the user of what will happen, as per
 * {@link android.app.VoiceInteractor.ConfirmationRequest
 * VoiceInteractor.ConfirmationRequest}.
 */
@Nullable
public VoiceInteractor.Prompt getVoicePrompt() {
    return mPrompt;
}
 
Example #16
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Return the set of options the user is picking from, as per
 * {@link android.app.VoiceInteractor.PickOptionRequest VoiceInteractor.PickOptionRequest}.
 */
public VoiceInteractor.PickOptionRequest.Option[] getOptions() {
    return mOptions;
}
 
Example #17
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Report an intermediate option selection from the request, without completing it (the
 * request is still active and the app is waiting for the final option selection),
 * resulting in a call to
 * {@link android.app.VoiceInteractor.PickOptionRequest#onPickOptionResult
 * VoiceInteractor.PickOptionRequest.onPickOptionResult} with false for finished.
 */
public void sendIntermediatePickOptionResult(
        VoiceInteractor.PickOptionRequest.Option[] selections, Bundle result) {
    sendPickOptionResult(false, selections, result);
}
 
Example #18
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Report the final option selection for the request, completing the request
 * and resulting in a call to
 * {@link android.app.VoiceInteractor.PickOptionRequest#onPickOptionResult
 * VoiceInteractor.PickOptionRequest.onPickOptionResult} with false for finished.
 * This finishes the request (it is no longer active).
 */
public void sendPickOptionResult(
        VoiceInteractor.PickOptionRequest.Option[] selections, Bundle result) {
    sendPickOptionResult(true, selections, result);
}
 
Example #19
Source File: VoiceInteractionSession.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Return the message informing the user of the completion, as per
 * {@link android.app.VoiceInteractor.CompleteVoiceRequest
 * VoiceInteractor.CompleteVoiceRequest}.
 */
@Nullable
public VoiceInteractor.Prompt getVoicePrompt() {
    return mPrompt;
}
 
Example #20
Source File: ICompositeActivity.java    From CompositeAndroid with Apache License 2.0 votes vote down vote up
VoiceInteractor getVoiceInteractor(); 
Example #21
Source File: ICompositeActivity.java    From CompositeAndroid with Apache License 2.0 votes vote down vote up
VoiceInteractor super_getVoiceInteractor();