Android Quick Shortcuts [passing Intent Extra(or Some Data) In Shortcuts.xml ]
While implementing the static Shortcuts using shortcut.xml, i would like to pass few bundle extras with my intent. need the passed extras to decide on few functionality in the targ
Solution 1:
I'm not sure if there is another way, but I use this:
<intentandroid:action="android.intent.action.VIEW"android:targetPackage="target.package"android:targetClass="activity.with.package"><extraandroid:name="extraID"android:value="extravalue" /></intent>
Then you can access extras as usual.
Solution 2:
Than why don't you create dynamic shortcuts?
ShortcutManagershortcutManager= getSystemService(ShortcutManager.class);
IntentthirdIntent=newIntent(this,ThirdActivity.class);
thirdIntent.setAction(Intent.ACTION_VIEW);
ShortcutInfothirdScreenShortcut=newShortcutInfo.Builder(this, "shortcut_third")
.setShortLabel("Third Activity")
.setLongLabel("This is long description for Third Activity")
.setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
.setIntent(thirdIntent)
.build();
shortcutManager.setDynamicShortcuts(Collections.singletonList(thirdScreenShortcut));
You can pass whatever you want to send in Intent
and access it to receiver activity.
Post a Comment for "Android Quick Shortcuts [passing Intent Extra(or Some Data) In Shortcuts.xml ]"