如何通过意图进入Android的语音搜索设置?
我想知道是否有一种方法可以在点击按钮后进入语音搜索设置 例如,要转到我们使用的定位服务:android.provider.Settings.ACTION\u Location\u SOURCE\u Settings。我搜索了类似于语音搜索设置的内容,但没有找到任何内容 有人能帮忙吗?如何通过意图进入Android的语音搜索设置?,android,Android,我想知道是否有一种方法可以在点击按钮后进入语音搜索设置 例如,要转到我们使用的定位服务:android.provider.Settings.ACTION\u Location\u SOURCE\u Settings。我搜索了类似于语音搜索设置的内容,但没有找到任何内容 有人能帮忙吗? 谢谢我找到了解决方案,希望能对您有所帮助: 预冻豆 Intent intent = new Intent(Intent.ACTION_MAIN); intent.setC
谢谢我找到了解决方案,希望能对您有所帮助: 预冻豆
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.google.android.voicesearch","com.google.android.voicesearch.VoiceSearchPreferences"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Post Jelly Bean包名不同,因此代码必须如下所示:
try {
final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.google.android.voicesearch",
"com.google.android.voicesearch.VoiceSearchPreferences"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (final Exception e) {
try {
final Intent i = new Intent(Intent.ACTION_MAIN);
i.setComponent(new ComponentName("com.google.android.googlequicksearchbox", "com.google.android.voicesearch.VoiceSearchPreferences"));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} catch (final Exception e) {
e.printStackTrace();
}
}