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.launcher4.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;/* w ww.ja va 2 s .com*/ } 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 = ensureValidName(context, intent, data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME)).toString(); 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:library.artaris.cn.library.utils.SystemUtils.java
/** * ???//from w w w . j a v a2s. co m * @param context * @param shortCutName * @param icon * @param cls */ public static void createDeskShortCut(Context context, String shortCutName, int icon, Class<?> cls) { Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); shortcutIntent.putExtra("duplicate", false); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortCutName); Parcelable ico = Intent.ShortcutIconResource.fromContext(context.getApplicationContext(), icon); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, ico); Intent intent = new Intent(context, cls); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); context.sendBroadcast(shortcutIntent); }
From source file:org.wso2.app.catalog.api.ApplicationManager.java
/** * Creates a webclip on the device home screen. * * @param url - URL should be passed in as a String. * @param title - Title(Web app title) should be passed in as a String. *//* w w w.jav a 2s . c o m*/ public void manageWebAppBookmark(String url, String title, String operationType) throws AppCatalogException { final Intent bookmarkIntent = new Intent(); final Intent actionIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); long urlHash = url.hashCode(); long uniqueId = (urlHash << MAX_URL_HASH) | actionIntent.hashCode(); actionIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId)); bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent); bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.ic_bookmark)); if (operationType != null) { if (resources.getString(R.string.operation_install).equalsIgnoreCase(operationType)) { bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action)); } else if (resources.getString(R.string.operation_uninstall).equalsIgnoreCase(operationType)) { bookmarkIntent .setAction(resources.getString(R.string.application_package_launcher_uninstall_action)); } else { throw new AppCatalogException("Cannot create webclip due to invalid operation type."); } } else { bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action)); } context.sendBroadcast(bookmarkIntent); }
From source file:ru.orangesoftware.financisto2.activity.PreferencesActivity.java
private Intent createShortcutIntent(String activity, String shortcutName, ShortcutIconResource shortcutIcon, String action) {//from w w w. j a v a2 s . c o m Intent shortcutIntent = new Intent(); shortcutIntent.setComponent(new ComponentName(this.getPackageName(), activity)); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, shortcutIcon); intent.setAction(action); return intent; }
From source file:com.imagine.BaseActivity.java
void addViewShortcut(String name, String path) { Intent viewIntent = new Intent(this, BaseActivity.class); viewIntent.setAction(Intent.ACTION_VIEW); viewIntent.setData(Uri.parse("file://" + path)); Intent launcherIntent = new Intent(); launcherIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, viewIntent); launcherIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name); final String EXTRA_SHORTCUT_DUPLICATE = "duplicate"; launcherIntent.putExtra(EXTRA_SHORTCUT_DUPLICATE, false); int icon = getResources().getIdentifier("icon", "drawable", getPackageName()); launcherIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, icon)); launcherIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(launcherIntent);/* ww w .j av a 2 s . c o m*/ }
From source file:library.artaris.cn.library.utils.SystemUtils.java
/** * ??/*from www . j a v a 2s .c o m*/ * @param context * @param shortCutName * @param iconId * @param presentIntent */ public static void createShortcut(Context context, String shortCutName, int iconId, Intent presentIntent) { Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); shortcutIntent.putExtra("duplicate", false); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortCutName); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, iconId)); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, presentIntent); context.sendBroadcast(shortcutIntent); }
From source file:fi.iki.murgo.irssinotifier.SettingsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode != ICB_HOST_REQUEST_CODE) { return;//from www . java2s . c o m } Preferences prefs = new Preferences(this); if (data == null || resultCode != Activity.RESULT_OK) { prefs.setIcbHost(null, null); } else { String hostName = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); Intent intent = (Intent) data.getExtras().get(Intent.EXTRA_SHORTCUT_INTENT); if (intent != null) { String intentUri = intent.toUri(0); prefs.setIcbHost(hostName, intentUri); } else { prefs.setIcbHost(null, null); } } handleIcb(); }
From source file:com.silentcircle.contacts.list.ShortcutIntentBuilder.java
private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName, String lookupKey, byte[] bitmapData) { Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); 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 {/* w ww.j a v a 2 s . co m*/ intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName); } mListener.onShortcutIntentCreated(contactUri, intent); }
From source file:com.dnielfe.manager.utils.SimpleUtils.java
public static void createShortcut(Activity main, String path) { File file = new File(path); try {/*from w w w . j a v a 2 s .com*/ // Create the intent that will handle the shortcut Intent shortcutIntent = new Intent(main, Browser.class); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); shortcutIntent.putExtra(Browser.EXTRA_SHORTCUT, path); // The intent to send to broadcast for register the shortcut intent Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, file.getName()); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(main, R.drawable.ic_launcher)); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); main.sendBroadcast(intent); Toast.makeText(main, main.getString(R.string.shortcutcreated), Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(main, main.getString(R.string.error), Toast.LENGTH_SHORT).show(); } }