Java 类android.app.VoiceInteractor 实例源码

项目:CompositeAndroid    文件:ActivityDelegate.java   
public VoiceInteractor getVoiceInteractor() {
    if (mPlugins.isEmpty()) {
        return getOriginal().super_getVoiceInteractor();
    }

    final ListIterator<ActivityPlugin> iterator = mPlugins.listIterator(mPlugins.size());

    final CallFun0<VoiceInteractor> superCall = new CallFun0<VoiceInteractor>(
            "getVoiceInteractor()") {

        @Override
        public VoiceInteractor call() {
            if (iterator.hasPrevious()) {
                return iterator.previous().getVoiceInteractor(this);
            } else {
                return getOriginal().super_getVoiceInteractor();
            }
        }
    };
    return superCall.call();
}
项目:io2015-codelabs    文件:CameraFragment.java   
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();
            }
        });
}
项目:speech    文件:VoiceInteractionActivity.java   
public Confirm(String ttsPrompt, String visualPrompt) {
    //super must come first, so their code is well wrong... shocker...
    super(new VoiceInteractor.Prompt(
                    new String[]{ttsPrompt}, visualPrompt
            )
            , null);
}
项目:speech    文件:VoiceInteractionActivity.java   
@Override
public void onConfirmationResult(boolean confirmed, Bundle result) {
    Bundle status = new Bundle();  //the picture should be in the bundle.
    VoiceInteractor.Request request = null;

    if (confirmed) {
        //here is where we would take the picture.  except I'm faking it.
        request = new VoiceInteractor.CompleteVoiceRequest(new VoiceInteractor.Prompt("Success"), status);
    } else {
        request = new VoiceInteractor.AbortVoiceRequest(new VoiceInteractor.Prompt("Too Complex"), status);
    }
    getVoiceInteractor().submitRequest(request);

    finish();
}
项目:CompositeAndroid    文件:BlueprintActivity.java   
@Override
public VoiceInteractor getVoiceInteractor() {
    return super.getVoiceInteractor();
}
项目:CompositeAndroid    文件:CompositeActivity.java   
@Override
public VoiceInteractor getVoiceInteractor() {
    return delegate.getVoiceInteractor();
}
项目:CompositeAndroid    文件:CompositeActivity.java   
@Override
public VoiceInteractor super_getVoiceInteractor() {
    return super.getVoiceInteractor();
}
项目:CompositeAndroid    文件:ActivityPlugin.java   
public VoiceInteractor getVoiceInteractor() {
    verifyMethodCalledFromDelegate("getVoiceInteractor()");
    return ((CallFun0<VoiceInteractor>) mSuperListeners.pop()).call();
}
项目:CompositeAndroid    文件:ActivityPlugin.java   
VoiceInteractor getVoiceInteractor(final CallFun0<VoiceInteractor> superCall) {
    synchronized (mSuperListeners) {
        mSuperListeners.push(superCall);
        return getVoiceInteractor();
    }
}
项目:Train-Track-Android    文件:VoiceActivity.java   
@Override
public void onResume() {
    super.onResume();
    Utils.log("onResume: ");
    Intent intent = getIntent();

    if (intent == null) {
        Utils.log("intent is null");
        finish();
        return;
    }

    String query = intent.getStringExtra(SearchManager.QUERY);
    Utils.log("onResume: Searching for: " + query);

    Utils.log("onResume: isVoiceInteraction: " + isVoiceInteraction());
    Utils.log("onResume: isVoiceInteractionRoot: " + isVoiceInteractionRoot());

    if (isVoiceInteraction()) {
        //One option can have many synonyms
        VoiceInteractor.PickOptionRequest.Option voiceOption1 =
                new VoiceInteractor.PickOptionRequest.Option("Green", 1);
        voiceOption1.addSynonym("Olive");
        voiceOption1.addSynonym("Emerald");

        VoiceInteractor.PickOptionRequest.Option voiceOption2 =
                new VoiceInteractor.PickOptionRequest.Option("Red", 1);
        voiceOption2.addSynonym("Crimson");
        voiceOption2.addSynonym("Burgundy");

        //Add as many options as you’d like within the option array, this will increase the chances of //a successful response.
        getVoiceInteractor()
                .submitRequest(new VoiceInteractor.PickOptionRequest(new VoiceInteractor.Prompt(new String[]{"What is your favorite color?"}, "What is your favorite color?"), new VoiceInteractor.PickOptionRequest.Option[]{voiceOption1, voiceOption2}, null) {
                    @Override
                    public void onPickOptionResult(boolean finished, Option[] selections, Bundle result) {
                        if (finished && selections.length == 1) {
                            //Use the index of the options array to determine what was said
                            selections[0].getIndex();
                        }
                    }

                    @Override
                    public void onCancel() {
                        getActivity().finish();
                    }
                });
    }
    finish();
}
项目:CompositeAndroid    文件:ICompositeActivity.java   
VoiceInteractor getVoiceInteractor();
项目:CompositeAndroid    文件:ICompositeActivity.java   
VoiceInteractor super_getVoiceInteractor();