如何隐藏吐司消息“您的音频将被发送到Google以提供语音识别服务."在Android中? [英] How to hide toast message “Your audio will be sent to google to provide speech recognition service.” in Android?

查看:51
本文介绍了如何隐藏吐司消息“您的音频将被发送到Google以提供语音识别服务."在Android中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用谷歌语音识别器在Android中集成语音服务,但是在按下麦克风按钮时却显示了这条烦人的吐司消息.请给我建议一种隐藏此吐司信息的方法.

I am using google speech recognizer for integrating voice services in Android but while pressing on mic button this annoying toast message is showing. Please suggest me a way to hide this toast message.

这是我的Java代码

public class FormActivity extends AppCompatActivity {

    AppCompatEditText mFeedbackView; 
    ImageView mFeedbackVoiceView;
    private final int REQ_CODE_SPEECH_INPUT_FEEDBACK = 100;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_form);
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        mVisitFeedbackView = findViewById(R.id.feedback);
        mFeedbackVoiceView = findViewById(R.id.feedback_voice);

        mFeedbackVoiceView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                promptSpeechInputFeedback();
            }
        });
    }
    private void promptSpeechInputFeedback() {
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.speech_prompt));
        try {
            startActivityForResult(intent, REQ_CODE_SPEECH_INPUT_FEEDBACK);
        } catch (ActivityNotFoundException a) {
            Toast.makeText(getApplicationContext(), getString(R.string.speech_not_supported), Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        switch (requestCode) {
            case REQ_CODE_SPEECH_INPUT_FEEDBACK: {
                if (resultCode == RESULT_OK && null != data) {
                    ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); 
                    mFeedbackView.setText(result.get(0));
                }
                break;
            }  
        }
    }
}

此问题与,但是对此没有解决方案.

This question is duplicate of How to hide toast" Your audio will be sent to google to provide speech recognition service." in Speech Recognizer? but there are no solution for this.

任何帮助将不胜感激.

推荐答案

基于android规定您无法隐藏系统吐司消息,因为您无权访问系统视图,

Based on android regulations you cannot hide system toast messages as you don't have the accesses to the system View,

仅在可以访问终端的越狱android中,您可以尝试这样做.

only in jailbrake android where you have access to the terminal you can try to do that.

这篇关于如何隐藏吐司消息“您的音频将被发送到Google以提供语音识别服务."在Android中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆