Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Intent shortcutIntent = new Intent(this.getApplicationContext(),
- Shortcut_Activity.class);
- shortcutIntent.setAction(Intent.ACTION_MAIN);
- Intent addIntent = new Intent();
- addIntent
- .putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
- addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
- addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
- Intent.ShortcutIconResource.fromContext(this.getApplicationContext(),
- R.drawable.ic_shortcut));
- addIntent.putExtra("ID", id); //THIS IS THE EXTRA DATA I WANT TO ATTACH
- addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
- this.getApplicationContext().sendBroadcast(addIntent);
- void returnShortcut(int rowId, String shortcutName) {
- Intent i = new Intent(this, ShowInfoActivity.class);
- i.setData(ContentUris.withAppendedId(BASE_URI, rowId));
- Intent shortcut = new Intent();
- shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, i);
- shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName);
- setResult(RESULT_OK, shortcut);
- finish();
- }
- private void addShortcut() {
- //Adding shortcut for MainActivity
- //on Home screen
- Intent shortcutIntent = new Intent(getApplicationContext(),
- HOMESHORTCUT.class);
- //Set Extra
- shortcutIntent.putExtra("extra", "shortCutTest ");
- 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);
- }
- //GET Extra in HOMESHORTCUT activity.
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mTextExtra=new TextView(this);
- Bundle bundel=getIntent().getExtras();
- String getExString=getIntent().getExtras().getString("extra");
- mTextExtra.setText(getExString);
- setContentView(mTextExtra);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement