2
在我的Android应用程序中,我创建了一个带磨损功能的通知,并添加了一个动作来识别语音输入并将语音文本发送到其他活动。我的问题是它只是在谷歌现在设置(英语)中识别所选语言,我想从波斯语获得声音。这我的代码:在Android Wear动作中更改语音识别器的语言
RemoteInput remoteInput = new RemoteInput.Builder("My_Const_String")
.setLabel("label when you talk")
.build();
Intent replayIntent = new Intent(context, MyTestActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, replayIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action action = new NotificationCompat.Action.Builder(
R.drawable.ic_btn, "Label when confirm your talk", pendingIntent)
.addRemoteInput(remoteInput)
.build();
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle("Title")
.setContentText("Content text")
.setSmallIcon(R.drawable.ic_stat_name)
.setContentText("My text02");
NotificationCompat.WearableExtender extender =
new NotificationCompat.WearableExtender();
extender.addAction(action);
builder.extend(extender);
NotificationManagerCompat mgr = NotificationManagerCompat.from(context);
int NotificatinId = 1;
mgr.notify(NotificatinId, builder.build());
另外我不想强制用户手动更改谷歌的设置。我试图增加额外的喜欢,但它没有奏效:
Intent i = new Intent();
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "fa_IR");
i.putExtra(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES, "fa_IR");
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "fa");
Bundle bundle = new Bundle();
bundle = i.getExtras();
RemoteInput remoteInput = new RemoteInput.Builder("My_Const_String")
.setLabel("label when you talk")
.addExtras(bundle)
.build();
波斯和波斯人都是一样的,它的支持谷歌。在Google App>设置>语音>语言中,您的手机上是否只有英文检查,或者您是否也检查过其他语言? –