I have three activities in my app and the initial activity is LauncherActivity,this is the starter class. I would like to launch an activity (named MainFormActivity) in my app using voice command. i.e, Google assistant.
Could anyone help me to achieve this?
I got the answer and would like to share here,
First, do the following step,
1. add action android:name="com.google.android.gms.actions.SEARCH_ACTION" />inside the activity tag and should specify an activity label.
2. add the java code inside the activity java class:
String query = "";
if (getIntent().getAction() != null && getIntent().getAction().equals("com.google.android.gms.actions.SEARCH_ACTION")) {
query = getIntent().getStringExtra(SearchManager.QUERY);
}