i have small practice app. i put some dynamic shortcut for my app.all shortcut works like i can able to open site from shortcut(google docs example) but now i want to open particular activity from this shorcut .so how can i do this.
and here is code of my work.
findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//open activity.
Intent intent=new Intent(MainActivity.this,Main2Activity.class);
ShortcutManager shortcutManager= (ShortcutManager) getSystemService(SHORTCUT_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
ShortcutInfo shortcutInfo=new ShortcutInfo.Builder(MainActivity.this,"shortcutID")
.setShortLabel("Shortcut Label")
.setIcon(Icon.createWithResource(MainActivity.this, R.drawable.ic_message))
.setIntent(new Intent(Intent.ACTION_VIEW))
.setActivity()
.build();
shortcutManager.addDynamicShortcuts(Arrays.asList(shortcutInfo));
}
}
});
so how can i open activity from first shortcut selection .waiting for reply
Create your intent for a specific component with a specified action and data like this.
And your shortcut set it with