How to open a specified activity inside my android application through voice command( google assistant) using android

2k Views Asked by At

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?

2

There are 2 best solutions below

1
varsha jeevan On BEST ANSWER

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);
}

1
Iaroslav Ternovyi On

After my searches, I can say that there is no way to do this. Your answer doesn't fit your question. Voice trigger SEARCH_ACTION is a search for "some stuff" in/on "Application"