My app maintains different clients data. For seeing each client data single activity is launched each time and depending on the bundle it shows particular client's data. Now, I want to create a shortcut on homescreen for any client So that, only that client data could be directly seen after clicking the shortcut. But My problem is how to give the extra data to activity while we click on shortcut So that, I could show that particular client data. Here is the code:
private void addShortcut() {
Intent shortcutIntent = new Intent(getApplicationContext(),MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(getApplicationContext(),
R.drawable.ic_launcher));
addIntent
.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
}
0 comments:
Post a Comment