Android Question [Solved] Intent to show Google App Voice Settings and Download Languages

Derek Johnson

Active Member
Licensed User
Longtime User
I'm working with Voice Recognition and I would like to show the Voice Settings to the user. I know this can be done but I can't figure out the exact intent required.

This is the screen that I want to show:

VoiceSettings.png

Could someone tell me what the Intent would be to show this screen and also the following one.(This is the Languages link on the previous screen)

Languages.png


Thanks


Derek
 

Derek Johnson

Active Member
Licensed User
Longtime User
Thanks Erel but that opens the wrong settings page. I've now got something else to try from here:

https://stackoverflow.com/questions...voice-recognition-settings-in-my-app/34738985

I've updated this - this code should work


B4X:
Process Globals
    Private NativeMe As JavaObject
'...
end sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer.
'...
    If FirstTime Then
        NativeMe.InitializeContext
    End If
end sub

Sub ShowSoundSettings

#if java
/**
 * Open speech recognition settings activity
 *
 * @return true in case activity was launched, false otherwise
 **/
import android.content.Intent;
import android.content.ComponentName;

public boolean openSpeechRecognitionSettings() {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    boolean started = false;
    ComponentName[] components = new ComponentName[]{
            new ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.settingsui.VoiceSearchPreferences"),
            new ComponentName("com.google.android.voicesearch", "com.google.android.voicesearch.VoiceSearchPreferences"),
            new ComponentName("com.google.android.googlequicksearchbox", "com.google.android.voicesearch.VoiceSearchPreferences"),
            new ComponentName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.velvet.ui.settings.VoiceSearchPreferences")
    };
    for (ComponentName componentName : components) {
        try {
            intent.setComponent(componentName);
            startActivity(intent);
            started = true;
            break;
        } catch (final Exception e) {
            /** Timber.e(e, null);  **/
        }
    }
    return started;
}

#end if
    Try
        Dim res As Boolean
        res=NativeMe.RunMethod("openSpeechRecognitionSettings", Null)
        Log("Launch result was " & res)
    Catch
        Log(LastException)
    End Try

End Sub

The above code is now correct

These were the errors before adding in the 2 Import Declarations
B4X:
javac 1.8.0_121
src\uk\org100\seethis\main.java:919: error: cannot find symbol
    Intent intent = new Intent(Intent.ACTION_MAIN);
    ^
  symbol:   class Intent
  location: class main

Do I need to create a declaration for 'Intent' or import something before this code?
 
Last edited:
Upvote 0

Derek Johnson

Active Member
Licensed User
Longtime User
yes, you need a import inside the inline java at the beginning
B4X:
import android.content.Intent;

Manfred,

Thanks

I've now got that working - just to say there were two extra lines that I needed to make it work.

B4X:
import android.content.Intent;
import android.content.ComponentName;

It looks like Google have altered the intent 3 times since they first started!
 
Upvote 0
Top