List of usage examples for android.content Intent EXTRA_SHORTCUT_NAME
String EXTRA_SHORTCUT_NAME
To view the source code for android.content Intent EXTRA_SHORTCUT_NAME.
Click Source Link
From source file:com.jefftharris.passwdsafe.LauncherRecordShortcuts.java
/** * Select the given record and return a result *///from w w w. j ava2 s . c om private void selectRecord(final String uuid) { switch (itsMode) { case SHORTCUT: { final ObjectHolder<Pair<Uri, String>> rc = new ObjectHolder<>(); PasswdSafeFileDataFragment.useOpenFileData(new PasswdFileDataUser() { @Override public void useFileData(@NonNull PasswdFileData fileData) { PwsRecord rec = fileData.getRecord(uuid); String title = fileData.getTitle(rec); rc.set(new Pair<>(fileData.getUri().getUri(), title)); } }); Pair<Uri, String> rcval = rc.get(); if (rcval != null) { Intent shortcutIntent = PasswdSafeUtil.createOpenIntent(rcval.first, uuid); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, rcval.second); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher_passwdsafe)); setResult(RESULT_OK, intent); } break; } case CHOOSE_RECORD: { Intent intent = new Intent(); intent.putExtra(PasswdSafeApp.RESULT_DATA_UUID, uuid); setResult(RESULT_OK, intent); break; } } finish(); }
From source file:com.ddj.launcher2.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;//www . j a v a2 s.c o m } Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (intent == null) { return; } // This name is only used for comparisons and notifications, so fall back to activity name // if not supplied String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (name == null) { try { PackageManager pm = context.getPackageManager(); ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0); name = info.loadLabel(pm).toString(); } catch (PackageManager.NameNotFoundException nnfe) { return; } } Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); // Queue the item up for adding if launcher has not loaded properly yet boolean launcherNotLoaded = LauncherModel.getCellCountX() <= 0 || LauncherModel.getCellCountY() <= 0; PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; if (mUseInstallQueue || launcherNotLoaded) { String spKey = LauncherUtil.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); } else { processInstallShortcut(context, info); } }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.FavouriteStopsFragment.java
/** * {@inheritDoc}//from w w w . java2 s . c om */ @Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { // Get the stopCode and cache the Activity. final String stopCode = String.valueOf(id); final Activity activity = getActivity(); Intent intent; // What happens when the user selects a list item depends on what mode // is active. if (isCreateShortcut) { // Set the Intent which is used when the shortcut is tapped. intent = new Intent(Intent.ACTION_MAIN); intent.setClass(activity, DisplayStopDataActivity.class); intent.setAction(DisplayStopDataActivity.ACTION_VIEW_STOP_DATA); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(DisplayStopDataActivity.ARG_STOPCODE, stopCode); // Set the Activity result to send back to the launcher, which // contains a name, Intent and icon. final Intent result = new Intent(); result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); result.putExtra(Intent.EXTRA_SHORTCUT_NAME, sd.getNameForStop(stopCode)); final Parcelable icon = Intent.ShortcutIconResource.fromContext(activity, R.drawable.appicon_favourite); result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); // Set the Activity result and exit. activity.setResult(Activity.RESULT_OK, result); activity.finish(); } else { // View bus stop times. callbacks.onShowBusTimes(stopCode); } }
From source file:com.slodin.transalarm.GeofenceTransitionsIntentService.java
/** * Posts a notification in the notification bar when a transition is detected. * If the user clicks the notification, control goes to the MainActivity. *//*from w w w . j a va2 s . c o m*/ private void sendNotificationCurrentLocation(String notificationDetails) { // Create an explicit content Intent that starts the main Activity. Intent notificationIntent = new Intent(getApplicationContext(), calPage.class) .putExtra(Intent.EXTRA_SHORTCUT_NAME, notificationDetails); // Construct a task stack. TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Add the main Activity to the task stack as the parent. stackBuilder.addParentStack(MainActivity.class); // Push the content Intent onto the stack. stackBuilder.addNextIntent(notificationIntent); // Get a PendingIntent containing the entire back stack. PendingIntent notificationPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); // Get a notification builder that's compatible with platform versions >= 4 NotificationCompat.Builder builder = new NotificationCompat.Builder(this); // Define the notification settings. builder.setSmallIcon(R.drawable.ic_stat_name) // In a real app, you may want to use a library like Volley // to decode the Bitmap. .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)) .setColor(Color.TRANSPARENT).setContentTitle("You are at: " + notificationDetails) .setContentText(getString(R.string.geofence_transition_notification_text)) .setContentIntent(notificationPendingIntent); // Dismiss notification once the user touches it. builder.setAutoCancel(true); // Get an instance of the Notification manager NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // Issue the notification mNotificationManager.notify(0, builder.build()); }
From source file:com.josephblough.sbt.activities.ShortcutActivity.java
private void createLauncher(final int searchType, final String criteria) { Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(this, this.getClass().getName()); shortcutIntent.putExtra(SEARCH_TYPE, searchType); if (criteria != null) shortcutIntent.putExtra(CRITERIA, criteria); // Pass back the criteria from the activity // Set up the container intent (the response to the caller) Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, ITEMS[searchType]); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, ICONS[searchType]); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); // Return the result to the launcher setResult(RESULT_OK, intent);/*from w ww.java2 s. c o m*/ finish(); }
From source file:cn.whereyougo.framework.utils.PackageManagerUtil.java
/** * ????/*w w w . j av a 2 s.c o m*/ * * @param mContext * * @param TagClass * ??? * @param iconResId * ?? * @param iconName * ?? */ public static void addShortCut2Desktop(Context mContext, Class<?> TagClass, int iconResId, String iconName) { SharedPreferences sp = mContext.getSharedPreferences("appinfo", Context.MODE_PRIVATE); if (!sp.getBoolean("shortcut_flag_icon", false)) { sp.edit().putBoolean("shortcut_flag_icon", true).commit(); LogUtil.d("shortcut", "first create successfull"); } else { LogUtil.d("shortcut", "no created"); return; } String ACTION_ADD_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT"; Intent intent = new Intent(); intent.setClass(mContext, TagClass); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT); Parcelable icon = Intent.ShortcutIconResource.fromContext(mContext, iconResId);// ??? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, iconName);// ?? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);// ?? addShortcut.putExtra("duplicate", false);// ???? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);// ?? mContext.sendBroadcast(addShortcut);// ?? }
From source file:dong.lan.tuyi.activity.SettingsFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.feedback: startActivity(new Intent(getActivity(), FeedBackActivity.class)); getActivity().overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right); break;//from w ww. j a v a 2 s.c o m case R.id.reset_lock: if (Config.isSetLock(getActivity())) Lock.locking(getActivity(), parent, Lock.RESETLOCK); else Show("?"); break; case R.id.add_shortcut: Intent addIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); Parcelable ioc = Intent.ShortcutIconResource.fromContext(getActivity(), R.drawable.logo); Intent clickIntent = new Intent(getActivity(), Welcome.class); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getResources().getString(R.string.app_name)); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, ioc); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, clickIntent); getActivity().sendBroadcast(addIntent); Show("????"); break; case R.id.rl_switch_notification: if (iv_switch_open_notification.getVisibility() == View.VISIBLE) { iv_switch_open_notification.setVisibility(View.INVISIBLE); iv_switch_close_notification.setVisibility(View.VISIBLE); rl_switch_sound.setVisibility(View.GONE); rl_switch_vibrate.setVisibility(View.GONE); textview1.setVisibility(View.GONE); textview2.setVisibility(View.GONE); chatOptions.setNotificationEnable(false); EMChatManager.getInstance().setChatOptions(chatOptions); HXSDKHelper.getInstance().getModel().setSettingMsgNotification(false); } else { iv_switch_open_notification.setVisibility(View.VISIBLE); iv_switch_close_notification.setVisibility(View.INVISIBLE); rl_switch_sound.setVisibility(View.VISIBLE); rl_switch_vibrate.setVisibility(View.VISIBLE); textview1.setVisibility(View.VISIBLE); textview2.setVisibility(View.VISIBLE); chatOptions.setNotificationEnable(true); EMChatManager.getInstance().setChatOptions(chatOptions); HXSDKHelper.getInstance().getModel().setSettingMsgNotification(true); } break; case R.id.rl_switch_sound: if (iv_switch_open_sound.getVisibility() == View.VISIBLE) { iv_switch_open_sound.setVisibility(View.INVISIBLE); iv_switch_close_sound.setVisibility(View.VISIBLE); chatOptions.setNoticeBySound(false); EMChatManager.getInstance().setChatOptions(chatOptions); HXSDKHelper.getInstance().getModel().setSettingMsgSound(false); } else { iv_switch_open_sound.setVisibility(View.VISIBLE); iv_switch_close_sound.setVisibility(View.INVISIBLE); chatOptions.setNoticeBySound(true); EMChatManager.getInstance().setChatOptions(chatOptions); HXSDKHelper.getInstance().getModel().setSettingMsgSound(true); } break; case R.id.rl_switch_vibrate: if (iv_switch_open_vibrate.getVisibility() == View.VISIBLE) { iv_switch_open_vibrate.setVisibility(View.INVISIBLE); iv_switch_close_vibrate.setVisibility(View.VISIBLE); chatOptions.setNoticedByVibrate(false); EMChatManager.getInstance().setChatOptions(chatOptions); HXSDKHelper.getInstance().getModel().setSettingMsgVibrate(false); } else { iv_switch_open_vibrate.setVisibility(View.VISIBLE); iv_switch_close_vibrate.setVisibility(View.INVISIBLE); chatOptions.setNoticedByVibrate(true); EMChatManager.getInstance().setChatOptions(chatOptions); HXSDKHelper.getInstance().getModel().setSettingMsgVibrate(true); } break; case R.id.btn_logout: // logout(); break; case R.id.ll_black_list: startActivity(new Intent(getActivity(), BlacklistActivity.class)); break; case R.id.offline_map_tv: startActivity(new Intent(getActivity(), OfflineMapActivity.class)); break; default: break; } }
From source file:cc.flydev.launcher.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;// w ww .j ava 2s .c om } if (DBG) Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0)); Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (intent == null) { return; } // This name is only used for comparisons and notifications, so fall back to activity name // if not supplied String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (name == null) { try { PackageManager pm = context.getPackageManager(); ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0); name = info.loadLabel(pm).toString(); } catch (PackageManager.NameNotFoundException nnfe) { return; } } Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); // Queue the item up for adding if launcher has not loaded properly yet LauncherAppState.setApplicationContext(context.getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); boolean launcherNotLoaded = (app.getDynamicGrid() == null); PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; String spKey = LauncherAppState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); if (!mUseInstallQueue && !launcherNotLoaded) { flushInstallQueue(context); } }
From source file:com.llf.android.launcher3.InstallShortcutReceiver.java
@Override public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;/*from ww w . j a va2 s . c o m*/ } if (DBG) Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0)); Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (intent == null) { return; } // This name is only used for comparisons and notifications, so fall // back to activity name // if not supplied String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (name == null) { try { PackageManager pm = context.getPackageManager(); ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0); name = info.loadLabel(pm).toString(); } catch (PackageManager.NameNotFoundException nnfe) { return; } } Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); // Queue the item up for adding if launcher has not loaded properly yet LauncherAppState.setApplicationContext(context.getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); boolean launcherNotLoaded = (app.getDynamicGrid() == null); PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; String spKey = LauncherAppState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); if (!mUseInstallQueue && !launcherNotLoaded) { flushInstallQueue(context); } }
From source file:com.aidy.launcher3.ui.receiver.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;// w w w . j ava2s.c o m } if (DBG) Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0)); Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (intent == null) { return; } // This name is only used for comparisons and notifications, so fall // back to activity name // if not supplied String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (name == null) { try { PackageManager pm = context.getPackageManager(); ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0); name = info.loadLabel(pm).toString(); } catch (PackageManager.NameNotFoundException nnfe) { return; } } Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); // Queue the item up for adding if launcher has not loaded properly yet LauncherAppState.setApplicationContext(context.getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); boolean launcherNotLoaded = (app.getDynamicGrid() == null); PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; String spKey = LauncherAppState.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); if (!mUseInstallQueue && !launcherNotLoaded) { flushInstallQueue(context); } }