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:de.baumann.browser.popups.Popup_bookmarks.java
private void setBookmarksList() { //display data final int layoutstyle = R.layout.list_item; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "bookmarks_title", "bookmarks_content", "bookmarks_creation" }; final Cursor row = db.fetchAllData(this); adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0) { @Override// w ww . j a v a2 s . c o m public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title")); final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content")); final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon")); final String bookmarks_attachment = row2 .getString(row2.getColumnIndexOrThrow("bookmarks_attachment")); final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation")); View v = super.getView(position, convertView, parent); final ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (bookmarks_attachment) { case "": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.star_outline); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.star_grey); break; } iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if (bookmarks_attachment.equals("")) { if (db.isExistFav("true")) { Snackbar.make(listView, R.string.bookmark_setFav_not, Snackbar.LENGTH_LONG).show(); } else { iv_attachment.setImageResource(R.drawable.star_grey); db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "true", bookmarks_creation); setBookmarksList(); sharedPref.edit().putString("startURL", bookmarks_content).apply(); Snackbar.make(listView, R.string.bookmark_setFav, Snackbar.LENGTH_LONG).show(); } } else { iv_attachment.setImageResource(R.drawable.star_outline); db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "", bookmarks_creation); setBookmarksList(); } } }); return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_bookmarksBY", "bookmarks_title"); sharedPref.edit().putString("filter_bookmarksBY", "bookmarks_title").apply(); editText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return db.fetchDataByFilter(constraint.toString(), note_search); } }); listView.setAdapter(adapter); //onClick function listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row = (Cursor) listView.getItemAtPosition(position); final String bookmarks_content = row.getString(row.getColumnIndexOrThrow("bookmarks_content")); sharedPref.edit().putString("openURL", bookmarks_content).apply(); finish(); } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title")); final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content")); final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon")); final String bookmarks_attachment = row2 .getString(row2.getColumnIndexOrThrow("bookmarks_attachment")); final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation")); final CharSequence[] options = { getString(R.string.menu_share), getString(R.string.menu_save), getString(R.string.bookmark_edit_title), getString(R.string.bookmark_remove_bookmark) }; new AlertDialog.Builder(Popup_bookmarks.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.bookmark_edit_title))) { sharedPref.edit().putString("edit_id", _id).apply(); sharedPref.edit().putString("edit_content", bookmarks_content).apply(); sharedPref.edit().putString("edit_icon", bookmarks_icon).apply(); sharedPref.edit().putString("edit_attachment", bookmarks_attachment).apply(); sharedPref.edit().putString("edit_creation", bookmarks_creation).apply(); editText.setVisibility(View.VISIBLE); helper_editText.showKeyboard(Popup_bookmarks.this, editText, 2, bookmarks_title, getString(R.string.bookmark_edit_title)); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(listView, R.string.bookmark_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setBookmarksList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.menu_share))) { final CharSequence[] options = { getString(R.string.menu_share_link), getString(R.string.menu_share_link_copy) }; new AlertDialog.Builder(Popup_bookmarks.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }) .setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.menu_share_link))) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, bookmarks_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, bookmarks_content); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.app_share_link)))); } if (options[item] .equals(getString(R.string.menu_share_link_copy))) { ClipboardManager clipboard = (ClipboardManager) Popup_bookmarks.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip( ClipData.newPlainText("text", bookmarks_content)); Snackbar.make(listView, R.string.context_linkCopy_toast, Snackbar.LENGTH_SHORT).show(); } } }).show(); } if (options[item].equals(getString(R.string.menu_save))) { final CharSequence[] options = { getString(R.string.menu_save_readLater), getString(R.string.menu_save_pass), getString(R.string.menu_createShortcut) }; new AlertDialog.Builder(Popup_bookmarks.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }) .setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.menu_save_pass))) { helper_editText.editText_savePass(Popup_bookmarks.this, listView, bookmarks_title, bookmarks_content); } if (options[item] .equals(getString(R.string.menu_save_readLater))) { DbAdapter_ReadLater db = new DbAdapter_ReadLater( Popup_bookmarks.this); db.open(); if (db.isExist(bookmarks_content)) { Snackbar.make(editText, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG).show(); } else { db.insert(bookmarks_title, bookmarks_content, "", "", helper_main.createDate()); Snackbar.make(listView, R.string.bookmark_added, Snackbar.LENGTH_LONG).show(); } } if (options[item] .equals(getString(R.string.menu_createShortcut))) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.setClassName(Popup_bookmarks.this, "de.baumann.browser.Browser_left"); i.setData(Uri.parse(bookmarks_content)); Intent shortcut = new Intent(); shortcut.putExtra("android.intent.extra.shortcut.INTENT", i); shortcut.putExtra("android.intent.extra.shortcut.NAME", "THE NAME OF SHORTCUT TO BE SHOWN"); shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, bookmarks_title); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext( Popup_bookmarks.this .getApplicationContext(), R.mipmap.ic_launcher)); shortcut.setAction( "com.android.launcher.action.INSTALL_SHORTCUT"); Popup_bookmarks.this.sendBroadcast(shortcut); Snackbar.make(listView, R.string.menu_createShortcut_success, Snackbar.LENGTH_SHORT).show(); } } }).show(); } } }).show(); return true; } }); }
From source file:org.nsdev.apps.superhappyhackmap.activities.MainActivity.java
private void addShortcut() { Intent shortcutIntent = new Intent(getApplicationContext(), ResetActivity.class); shortcutIntent.setAction(HackReceiver.ACTION_RESET_LAST_HACK); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Reset Sojourner"); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.mipmap.ic_reset_shortcut)); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getApplicationContext().sendBroadcast(addIntent); Toast.makeText(getApplicationContext(), "Sojourner reset shortcut created in launcher.", Toast.LENGTH_LONG) .show();/* w w w . j a v a 2s. c o m*/ }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Allows to install a new icon for the application. * * This method need two additional permissions in the application: * * <code>// w ww . j a v a 2s.c o m * <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> * </code> * * @param context The application context. * @param appMain The application main class * @param appName The application name * @param appIcon The bitmap of the application icon. Can be null. If null, the * appIconResId must be provided. * @param appIconResId Specify this only if no bitmap is set in the call to this method. */ public static void application_shortcutAdd(Context context, Class appMain, String appName, Bitmap appIcon, int appIconResId, boolean removeCurrent) { // Intent launcher of the application Intent shortcutIntent = new Intent("android.intent.action.MAIN"); shortcutIntent.addCategory("android.intent.category.LAUNCHER"); shortcutIntent.setClass(context, appMain); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //Intent to add the new application icon. // // Decorate the shortcut Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName); if (appIcon != null) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, appIcon); } else if (appIconResId != 0) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context.getApplicationContext(), appIconResId)); } // Inform launcher to create shortcut addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); context.sendBroadcast(addIntent); }
From source file:org.openintents.notepad.NoteEditor.java
/** * Return intent data when invoked with/*ww w .j av a2 s.com*/ * action=android.intent.action.CREATE_SHORTCUT */ private void createShortcut() { Intent intent = new Intent(Intent.ACTION_INSERT, Notes.CONTENT_URI, getApplicationContext(), NoteEditor.class); Intent result = new Intent(); result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher_notepad)); result.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.new_note)); setResult(RESULT_OK, result); finish(); }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Deletes a application desktop shortcut icon. * * This method need two additional permissions in the application: * * <code>/*from w w w .j ava 2 s. com*/ * <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" /> * </code> * * @param context The application context. * @param appClass Shortcut's activity class. * @param appName The shortcut's name */ public static void application_shortcutRemove_method1(Context context, Class appClass, String appName) { Intent shortcutIntent = new Intent(context, appClass); shortcutIntent.setAction(Intent.ACTION_MAIN); Intent delIntent = new Intent(); delIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); delIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName); // Inform launcher to remove shortcut delIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); context.sendBroadcast(delIntent); }
From source file:com.markupartist.sthlmtraveling.PlannerFragment.java
/** * Setup a search short cut./*from w ww .j a v a 2 s. c om*/ * * @param startPoint * the start point * @param endPoint * the end point */ protected void onCreateShortCut(Site startPoint, Site endPoint, String name) { Uri routesUri = RoutesActivity.createRoutesUri(startPoint, endPoint, null, true); Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, routesUri, getActivity(), RoutesActivity.class); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Then, 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, name); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(getActivity(), R.drawable.shortcut); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); // Now, return the result to the launcher getActivity().setResult(Activity.RESULT_OK, intent); getActivity().finish(); }
From source file:com.android.purenexussettings.TinkerActivity.java
@Override protected void onActivityResult(int paramRequest, int paramResult, Intent paramData) { super.onActivityResult(paramRequest, paramResult, paramData); if (paramResult != -1 || paramData == null) { return;// w w w . j ava 2s . c om } switch (paramRequest) { case REQUEST_CREATE_SHORTCUT: Intent localIntent = paramData.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); localIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, paramData.getStringExtra(Intent.EXTRA_SHORTCUT_NAME)); String keystring = localIntent.toUri(0).replaceAll("com.android.contacts.action.QUICK_CONTACT", Intent.ACTION_VIEW); Settings.Global.putString(getContentResolver(), TinkerActivity.mPrefKey, keystring); onBackPressed(); return; default: } }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Deletes a application desktop shortcut icon. * * Note:/*from w ww .j a va 2 s .co m*/ * Manual way. * * This method need two additional permissions in the application: * * <code> * <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" /> * </code> * * @param context The application context. * @param appClass Shortcut's activity class. */ public static void application_shortcutRemove_method2(Context context, Class appClass, String appName) { Intent intent = new Intent(); String oldShortcutUri = "#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;package=" + appClass.getPackage().getName() + ";component=" + appClass.getPackage().getName() + "/." + appClass.getSimpleName() + ";end"; try { Intent altShortcutIntent = Intent.parseUri(oldShortcutUri, 0); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, altShortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName); //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } catch (URISyntaxException e) { } intent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); context.sendBroadcast(intent); }
From source file:com.xabber.android.ui.activity.ContactList.java
private void createShortcut(AbstractContact abstractContact) { Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, ChatViewer.createShortCutIntent(this, abstractContact.getAccount(), abstractContact.getUser())); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, abstractContact.getName()); Bitmap bitmap;/*from w ww. j a v a2 s .co m*/ if (MUCManager.getInstance().hasRoom(abstractContact.getAccount(), abstractContact.getUser())) { bitmap = AvatarManager.getInstance().getRoomBitmap(abstractContact.getUser()); } else { bitmap = AvatarManager.getInstance().getUserBitmap(abstractContact.getUser()); } intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, AvatarManager.getInstance().createShortcutBitmap(bitmap)); setResult(RESULT_OK, intent); }
From source file:org.mozilla.gecko.GeckoAppShell.java
public static void createShortcut(final String aTitle, final String aURI, final Bitmap aIcon, final String aType) { getHandler().post(new Runnable() { public void run() { Log.w(LOGTAG, "createShortcut for " + aURI + " [" + aTitle + "] > " + aType); // the intent to be launched by the shortcut Intent shortcutIntent = new Intent(); if (aType.equalsIgnoreCase("webapp")) { shortcutIntent.setAction(GeckoApp.ACTION_WEBAPP); shortcutIntent.setData(Uri.parse(aURI)); } else { shortcutIntent.setAction(GeckoApp.ACTION_BOOKMARK); shortcutIntent.setData(Uri.parse(aURI)); }//from w w w . j a va 2s .c om shortcutIntent.setClassName(GeckoApp.mAppContext, GeckoApp.mAppContext.getPackageName() + ".App"); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); if (aTitle != null) intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, aTitle); else intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, aURI); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, getLauncherIcon(aIcon)); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); GeckoApp.mAppContext.sendBroadcast(intent); } }); }