微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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,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();

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。