如何使用Android编程打开S语音

时间:2016-08-14 14:05:32

标签: android android-intent voice-recognition

我在Galaxy S4中使用Android 5.0。当我双击主页按钮时,S Voice打开。我想让代码打开它。我使用下面的代码,但代码只打开谷歌语音。如何在没有任何配置的情况下打开S Voice?非常感谢你

        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
        try {
            startActivityForResult(intent, 1);
        } catch (ActivityNotFoundException a) {
            Toast.makeText(this, "Oops! Your device doesn't support Speech to Text",Toast.LENGTH_SHORT).show();
        }

这是S-Voice

enter image description here

更新:我安装了软件Dexplorer,找到了Svoice。但是,我无法访问以查看AndroidManifest.xml

enter image description here

1 个答案:

答案 0 :(得分:1)

我安装的S-Voice版本将响应以下任何意图操作:

            final String SVOICE_PACKAGE_NAME = "com.vlingo.midas";
            final String SVOICE_LISTEN_ACTION = "com.sec.action.SVOICE";

            final Intent intent = new Intent();
            intent.setPackage(SVOICE_PACKAGE_NAME);

            intent.setAction(SVOICE_LISTEN_ACTION);

            // intent.setAction(Intent.ACTION_VOICE_COMMAND);

            // intent.setAction(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
            // intent.putExtra(RecognizerIntent.EXTRA_SECURE, false);

            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

            try {
                startActivity(intent);
            } catch (final ActivityNotFoundException e) {
                e.printStackTrace();
            } catch (final Exception e) {
                e.printStackTrace();
            }