Android - 当前语音识别服务的名称是什么

时间:2016-06-17 03:53:19

标签: android service voice-recognition

我认为我使用以下代码获得当前语音识别。

String serviceComponent = Settings.Secure.getString(mContext.getContentResolver(),
                        Settings.Secure.VOICE_RECOGNITION_SERVICE);

应该这样做,但Settings.Secure.VOICE_RECOGNITION_SERVICE无法识别。

1 个答案:

答案 0 :(得分:1)

第一个结果应该是默认提供者。如果列表为空,则没有:

        final List<ResolveInfo> services = ctx.getPackageManager().queryIntentServices(
                new Intent(RecognitionService.SERVICE_INTERFACE), 0);

        String packageName = "";
        String serviceName = "";

        for (final ResolveInfo info : services) {
                packageName = info.serviceInfo.packageName;
                serviceName = info.serviceInfo.name;
        }