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.android.contacts.common.list.ShortcutIntentBuilder.java
private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName, String lookupKey, byte[] bitmapData) { Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); // Use an implicit intent without a package name set. It is reasonable for a disambiguation // dialog to appear when opening QuickContacts from the launcher. Plus, this will be more // resistant to future package name changes done to Contacts. Intent shortcutIntent = new Intent(ContactsContract.QuickContact.ACTION_QUICK_CONTACT); // When starting from the launcher, start in a new, cleared task. // CLEAR_WHEN_TASK_RESET cannot reset the root of a task, so we // clear the whole thing preemptively here since QuickContactActivity will // finish itself when launching other detail activities. We need to use // Intent.FLAG_ACTIVITY_NO_ANIMATION since not all versions of launcher will respect // the INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION intent extra. shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION); // Tell the launcher to not do its animation, because we are doing our own shortcutIntent.putExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION, true); shortcutIntent.setDataAndType(contactUri, contentType); shortcutIntent.putExtra(ContactsContract.QuickContact.EXTRA_EXCLUDE_MIMES, (String[]) null); final Bitmap icon = generateQuickContactIcon(drawable); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); if (TextUtils.isEmpty(displayName)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.missing_name)); } else {/*from ww w . ja va 2 s . co m*/ intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName); } mListener.onShortcutIntentCreated(contactUri, intent); }
From source file:org.protocoder.appApi.ProtoScripts.java
public void addShortcut(String folder, String name) { Project p = ProjectManager.getInstance().get(folder, name); Intent.ShortcutIconResource icon;//from ww w .j a va 2 s . c o m //TODO remove this way of selecting icons if (folder.equals("examples")) { icon = Intent.ShortcutIconResource.fromContext(mProtocoder.a, R.drawable.protocoder_script_example); } else { icon = Intent.ShortcutIconResource.fromContext(mProtocoder.a, R.drawable.protocoder_script_project); } try { Intent shortcutIntent = new Intent(mProtocoder.a, AppRunnerActivity.class); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); String script = ProjectManager.getInstance().getCode(p); shortcutIntent.putExtra(Project.NAME, p.getName()); shortcutIntent.putExtra(Project.FOLDER, p.getFolder()); final Intent putShortCutIntent = new Intent(); putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, p.getName()); putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); putShortCutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); mProtocoder.a.sendBroadcast(putShortCutIntent); } catch (Exception e) { // TODO } // Show toast Toast.makeText(mProtocoder.a, "Adding shortcut for " + p.getName(), Toast.LENGTH_SHORT).show(); }
From source file:com.android.contacts.ShortcutIntentBuilder.java
private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName, String lookupKey, byte[] bitmapData) { Intent intent = null;//from w w w . ja v a 2s. c o m if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } if (BuildCompat.isAtLeastO()) { final long contactId = ContentUris.parseId(contactUri); final ShortcutManager sm = (ShortcutManager) mContext.getSystemService(Context.SHORTCUT_SERVICE); final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext); final ShortcutInfo shortcutInfo = dynamicShortcuts.getQuickContactShortcutInfo(contactId, lookupKey, displayName); if (shortcutInfo != null) { intent = sm.createShortcutResultIntent(shortcutInfo); } } final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); final Intent shortcutIntent = ImplicitIntentsUtil.getIntentForQuickContactLauncherShortcut(mContext, contactUri); intent = intent == null ? new Intent() : intent; final Bitmap icon = generateQuickContactIcon(drawable); if (BuildCompat.isAtLeastO()) { final IconCompat compatIcon = IconCompat.createWithAdaptiveBitmap(icon); compatIcon.addToShortcutIntent(intent, null, mContext); } else { intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); } intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName); mListener.onShortcutIntentCreated(contactUri, intent); }
From source file:com.todoroo.astrid.activity.FilterListFragment.java
/** * Creates a shortcut on the user's home screen * * @param shortcutIntent//from www . ja v a2 s.c om * @param label */ private static void createShortcut(Activity activity, Filter filter, Intent shortcutIntent, String label) { if (label.length() == 0) return; Bitmap bitmap = superImposeListIcon(activity, filter.listingIcon, filter.listingTitle); Intent createShortcutIntent = new Intent(); createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label); createShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); createShortcutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); //$NON-NLS-1$ activity.sendBroadcast(createShortcutIntent); Toast.makeText(activity, activity.getString(R.string.FLA_toast_onCreateShortcut, label), Toast.LENGTH_LONG) .show(); }
From source file:com.duy.pascal.ui.file.FileManager.java
public Intent createShortcutIntent(Context context, File file) { // create shortcut if requested Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(context, R.mipmap.ic_launcher); Intent intent = new Intent(); Intent launchIntent = new Intent(context, SplashScreenActivity.class); launchIntent.putExtra(CompileManager.EXTRA_FILE, file); launchIntent.setAction("run_from_shortcut"); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, file.getName()); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); return intent; }
From source file:com.silentcircle.contacts.list.ShortcutIntentBuilder.java
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) { Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); Bitmap bitmap = null;/*www . j av a 2 s . com*/ Uri phoneUri = null; if (Intent.ACTION_CALL.equals(shortcutAction)) { // Make the URI a direct tel: URI so that it will always continue to work phoneUri = Uri.fromParts(Constants.SCHEME_TEL, phoneNumber, null); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.badge_action_call); // } else { // phoneUri = Uri.fromParts(Constants.SCHEME_SMSTO, phoneNumber, null); // bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, // R.drawable.badge_action_sms); } Intent shortcutIntent = new Intent(shortcutAction, phoneUri); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName); mListener.onShortcutIntentCreated(uri, intent); }
From source file:com.android.contacts.common.list.ShortcutIntentBuilder.java
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) { Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); Bitmap bitmap;/* ww w . j av a2s. c o m*/ Uri phoneUri; if (Intent.ACTION_CALL.equals(shortcutAction)) { // Make the URI a direct tel: URI so that it will always continue to work phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_call); } else { phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_message_24dp); } Intent shortcutIntent = new Intent(shortcutAction, phoneUri); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } if (TextUtils.equals(shortcutAction, Intent.ACTION_CALL)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.call_by_shortcut, displayName)); } else if (TextUtils.equals(shortcutAction, Intent.ACTION_SENDTO)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.sms_by_shortcut, displayName)); } mListener.onShortcutIntentCreated(uri, intent); }
From source file:com.mobileglobe.android.customdialer.common.list.ShortcutIntentBuilder.java
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) { Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); Bitmap bitmap;/* ww w .java2 s . c o m*/ Uri phoneUri; if (Intent.ACTION_CALL.equals(shortcutAction)) { // Make the URI a direct tel: URI so that it will always continue to work phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_call); } else { phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_message_24dp_mirrored); } Intent shortcutIntent = new Intent(shortcutAction, phoneUri); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } if (TextUtils.equals(shortcutAction, Intent.ACTION_CALL)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.call_by_shortcut, displayName)); } else if (TextUtils.equals(shortcutAction, Intent.ACTION_SENDTO)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.sms_by_shortcut, displayName)); } mListener.onShortcutIntentCreated(uri, intent); }
From source file:the.joeapollo.utils.ApolloUtils.java
/** * Used to create shortcuts for an artist, album, or playlist that is then * placed on the default launcher homescreen * //from ww w. j a v a2 s. c o m * @param displayName The shortcut name * @param id The ID of the artist, album, playlist, or genre * @param mimeType The MIME type of the shortcut * @param context The {@link Context} to use to */ public static void createShortcutIntent(final String displayName, final Long id, final String mimeType, final SherlockFragmentActivity context) { try { final ImageFetcher fetcher = getImageFetcher(context); Bitmap bitmap = null; if (mimeType.equals(MediaStore.Audio.Albums.CONTENT_TYPE)) { bitmap = fetcher.getCachedBitmap(displayName + Config.ALBUM_ART_SUFFIX); } else { bitmap = fetcher.getCachedBitmap(displayName); } if (bitmap == null) { bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.default_artwork); } // Intent used when the icon is touched final Intent shortcutIntent = new Intent(context, ShortcutActivity.class); shortcutIntent.setAction(Intent.ACTION_VIEW); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); shortcutIntent.putExtra(Config.ID, id); shortcutIntent.putExtra(Config.NAME, displayName); shortcutIntent.putExtra(Config.MIME_TYPE, mimeType); // Intent that actually sets the shortcut final Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapUtils.resizeAndCropCenter(bitmap, 96)); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); context.sendBroadcast(intent); Toast.makeText(context, displayName + " " + context.getString(R.string.pinned_to_home_screen), Toast.LENGTH_LONG).show(); } catch (final Exception e) { Log.e("ApolloUtils", "createShortcutIntent - " + e); Toast.makeText(context, displayName + " " + context.getString(R.string.could_not_be_pinned_to_home_screen), Toast.LENGTH_LONG).show(); } }
From source file:com.andrew.apollo.utils.ApolloUtils.java
/** * Used to create shortcuts for an artist, album, or playlist that is then * placed on the default launcher homescreen * //w w w . j ava 2s. c o m * @param displayName The shortcut name * @param id The ID of the artist, album, playlist, or genre * @param mimeType The MIME type of the shortcut * @param context The {@link Context} to use to */ public static void createShortcutIntent(final String displayName, final Long id, final String mimeType, final SherlockFragmentActivity context) { try { final ImageFetcher fetcher = getImageFetcher(context); Bitmap bitmap = null; if (mimeType.equals(MediaStore.Audio.Albums.CONTENT_TYPE)) { bitmap = fetcher.getCachedBitmap(displayName + Config.ALBUM_ART_SUFFIX); } else { bitmap = fetcher.getCachedBitmap(displayName); } if (bitmap == null) { bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.default_artwork); } // Intent used when the icon is touched final Intent shortcutIntent = new Intent(context, ShortcutActivity.class); shortcutIntent.setAction(Intent.ACTION_VIEW); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); shortcutIntent.putExtra(Config.ID, id); shortcutIntent.putExtra(Config.NAME, displayName); shortcutIntent.putExtra(Config.MIME_TYPE, mimeType); // Intent that actually sets the shortcut final Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapUtils.resizeAndCropCenter(bitmap, 96)); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); context.sendBroadcast(intent); Crouton.makeText(context, displayName + " " + context.getString(R.string.pinned_to_home_screen), Crouton.STYLE_CONFIRM).show(); } catch (final Exception e) { Log.e("ApolloUtils", "createShortcutIntent - " + e); Crouton.makeText(context, displayName + " " + context.getString(R.string.could_not_be_pinned_to_home_screen), Crouton.STYLE_ALERT).show(); } }