How to add dynamic shortcut to google assistant shortcuts

66 Views Asked by At

I made a simple application with a single shortcut:

    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            makeShortcut();
    
        }
    private void makeShortcut(){
        Intent intent = new Intent(this, MainActivity.class);
        intent.setPackage("com.mypackage.httprequestassistantshorcuts");
        intent.setAction(Intent.ACTION_VIEW);
    
        ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(this, "somethingId")
                .setShortLabel("Order coffee")
                .setLongLabel("Order a cup of coffee")
                .addCapabilityBinding("actions.intent.ORDER_MENU_ITEM")
                .setIntent(intent)
                .build();
    
        ShortcutManagerCompat.pushDynamicShortcut(this, shortcutInfo);
    
    }
}

My important build.gradle dependencies :

implementation "androidx.core:core:1.6.0"
implementation "androidx.core:core-google-shortcuts:1.1.0"

This shortcut is visible when I hold down the application icon, but how can I make my application's dynamic shortcut visible when I go to Google Assistant Settings > Shortcuts > Explore? I don't see my app or its shortcuts there.

I installed my application on my smartphone via play.google.com and setting myself as a tester of this application.

0

There are 0 best solutions below