如何以编程方式从另一个应用 android 打开 Google 设置的下载语言

How to open Download Languages of Google Settings from another app android programmatically

我想打开 Google 设置的下载语言,以便用户可以下载他的语言以使用语音识别器离线发送文本。

像这样打开下载语言 (Kotlin):

try {
    startActivityForResult(Intent(android.provider.Settings.ACTION_VOICE_INPUT_SETTINGS), 0)
}catch (ex : Exception){
    ex.printStackTrace()
}

并向用户显示此页面:

我不知道如何打开 Google 设置的下载语言。 你能帮帮我吗?

试试这个:

fun openSpeechRecognitionSettings() {
    val intent = Intent(Intent.ACTION_MAIN)
    intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
    val components = arrayOf(ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.settingsui.VoiceSearchPreferences"), ComponentName("com.google.android.voicesearch", "com.google.android.voicesearch.VoiceSearchPreferences"), ComponentName("com.google.android.googlequicksearchbox", "com.google.android.voicesearch.VoiceSearchPreferences"), ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velvet.ui.settings.VoiceSearchPreferences"))
    for (componentName in components) {
        try {
            intent.component = componentName
            startActivity(intent)
            break
        } catch (e: Exception) {
            TODO("handle me")
        }
    }
}

请注意,它将打开设置页面,而不是下载语言页面。