How show “Voice Input and Output” settings page fr

2019-04-13 06:09发布

问题:

To help the user choose the settings I want from my application to open the Voice Input and Output settings page. I can just open the settings (Settings.ACTION_SETTINGS), I can open the various pages out there (Settings.ACTION_XXXX_SETTINGS) - but it can not find how to do it for Voice Input and Output page.

Any idea?

P.S. I try check source Settings.apk, but no one not using VoiceInputOutputSettings.java

回答1:

The following is found in Android 2.3.3 source code git:

 501         <activity android:name="VoiceInputOutputSettings"
 502                 android:label="@string/voice_input_output_settings">
 503             <intent-filter>
 504                 <action android:name="android.intent.action.MAIN" />
 505                 <action android:name="com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS" />
 506                 <category android:name="android.intent.category.DEFAULT" />
 507             </intent-filter>
 508         </activity>
 509 
 510         <activity android:name="TextToSpeechSettings" android:label="@string/tts_settings">
 511             <intent-filter>
 512                 <action android:name="android.intent.action.MAIN" />
 513                 <action android:name="com.android.settings.TTS_SETTINGS" />
 514                 <category android:name="android.intent.category.DEFAULT" />
 515             </intent-filter>
 516         </activity>

There may not be official constant for these two actions. But you can try "com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS" and "com.android.settings.TTS_SETTINGS", it works on my Nexus S.



回答2:

This is my code working with Android 2.2

final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(ComponentName.unflattenFromString("com.android.settings/.TextToSpeechSettings"));
intent.addCategory(Intent.CATEGORY_LAUNCHER );
startActivity(intent);

See also: how to show up the settings for text to speech in my app?



回答3:

This code works well for showing voice input/output settings page. Hope this works for you.

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.settings","com.android.settings.VoiceInputOutputSettings"));     
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);