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.pindroid.activity.ChooseTagShortcut.java
public void onTagSelected(String tag) { final Intent shortcutIntent = IntentHelper.ViewBookmarks(tag, username, null, this); final ShortcutIconResource iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_shortcut);/*from w w w .ja va2 s . c o m*/ final Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, tag); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); setResult(RESULT_OK, intent); finish(); }
From source file:com.lee.sdk.utils.Utils.java
/** * ????//from w w w .j av a 2 s.com * * @param activity ?Activity??? * @param nameId ???? * @param iconId ?? * @param appendFlags ????IntentFlag */ public static void addShortcut(Activity activity, int nameId, int iconId, int appendFlags) { Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // ???? shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, activity.getString(nameId)); shortcut.putExtra("duplicate", false); // ???? // ?Activity??? ComponentName comp = new ComponentName(activity.getPackageName(), activity.getClass().getName()); Intent intent = new Intent(Intent.ACTION_MAIN).setComponent(comp); if (appendFlags != 0) { intent.addFlags(appendFlags); } shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); // ?? ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(activity, iconId); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); activity.sendBroadcast(shortcut); }
From source file:de.Maxr1998.xposed.maxlock.ui.MasterSwitchShortcutActivity.java
@SuppressLint("WorldReadableFiles") @Override/*from w w w . j av a2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getIntent().getBooleanExtra("LaunchOnly", false)) { // Launch Log.d("MaxLock", "Launching shortcut"); //noinspection deprecation prefsPackages = getSharedPreferences(Common.PREFS_PACKAGES, Context.MODE_WORLD_READABLE); if (prefsPackages.getBoolean(Common.MASTER_SWITCH_ON, true)) { setContentView(R.layout.activity_lock); Fragment frag = new LockFragment(); Bundle b = new Bundle(1); b.putString(Common.INTENT_EXTRAS_PKG_NAME, getString(R.string.unlock_master_switch)); frag.setArguments(b); getSupportFragmentManager().beginTransaction().replace(R.id.frame_container, frag).commit(); } else { prefsPackages.edit().putBoolean(Common.MASTER_SWITCH_ON, true).commit(); Toast.makeText(this, getString(R.string.toast_master_switch_on), Toast.LENGTH_LONG).show(); fireIntentAndFinish(); } } else { // Create shortcut Log.d("MaxLock", "Creating shortcut"); Intent shortcut = new Intent(this, MasterSwitchShortcutActivity.class); shortcut.putExtra("LaunchOnly", true); Intent install = new Intent(); install.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.toggle_master_switch)); install.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.mipmap.ic_launcher)); install.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut); setResult(RESULT_OK, install); fireIntentAndFinish(); } }
From source file:com.jefftharris.passwdsafe.LauncherFileShortcuts.java
@Override public void openFile(Uri uri, String fileName) { if (itsIsDefaultFile || (uri != null)) { Intent openIntent = null;// ww w . j av a 2 s . co m if (uri != null) { openIntent = PasswdSafeUtil.createOpenIntent(uri, null); } Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, openIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, fileName); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher_passwdsafe)); setResult(RESULT_OK, intent); } finish(); }
From source file:cm.aptoide.ptdev.preferences.ManagerPreferences.java
private void removeLauncherShortcut(Context context) { final Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setComponent(new ComponentName(context.getPackageName(), "cm.aptoide.ptdev.Start")); final Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, Aptoide.getConfiguration().getMarketName()); shortcutIntent.setComponent(new ComponentName(context.getPackageName(), "cm.aptoide.ptdev.Start")); intent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); context.sendBroadcast(intent, null); }
From source file:com.metinkale.prayerapp.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (App.getContext() == null) { App.setContext(this); }/* w ww. j av a 2 s . c om*/ if (Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) { int id = R.mipmap.ic_launcher; switch (mNavPos) { case 1: id = R.mipmap.ic_compass; break; case 2: id = R.mipmap.ic_names; break; case 3: id = R.mipmap.ic_calendar; break; case 4: id = R.mipmap.ic_tesbihat; break; case 7: id = R.mipmap.ic_zikr; break; } Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, id); Intent intent = new Intent(); Intent launchIntent = new Intent(this, getClass()); launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); launchIntent.putExtra("duplicate", false); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getResources().getStringArray(R.array.dropdown)[mNavPos]); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); setResult(RESULT_OK, intent); finish(); } if (!Utils.askLang(this)) { Utils.init(this); Changelog.start(this); } }
From source file:org.mozilla.fennec_satyanarayan.LauncherShortcuts.java
public void onListItemClick(int id) { HashMap<String, String> map = mWebappsList.get(id); String uri = map.get("uri").toString(); String title = map.get("title").toString(); String appKey = map.get("appKey").toString(); String favicon = map.get("favicon").toString(); File manifestFile = new File(mWebappsFolder, appKey + "/manifest.json"); // Parse the contents into a string String manifestJson = new String(); try {//ww w. java 2s. c o m BufferedReader in = new BufferedReader(new FileReader(manifestFile)); String line = new String(); while ((line = in.readLine()) != null) { manifestJson += line; } } catch (IOException e) { } try { JSONObject manifest = (JSONObject) new JSONTokener(manifestJson).nextValue(); uri += manifest.getString("launch_path"); } catch (JSONException e) { } Intent shortcutintent = new Intent("org.mozilla.gecko.WEBAPP"); shortcutintent.setClass(this, App.class); shortcutintent.putExtra("args", "--webapp=" + uri); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutintent); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int size; switch (dm.densityDpi) { case DisplayMetrics.DENSITY_MEDIUM: size = 48; break; case DisplayMetrics.DENSITY_HIGH: size = 72; break; default: size = 72; } Bitmap bitmap = BitmapFactory.decodeFile(favicon); if (bitmap != null) { Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, size, size, true); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, scaledBitmap); } // Now, return the result to the launcher setResult(RESULT_OK, intent); finish(); }
From source file:kinsleykajiva.co.zw.cutstudentapp.Settinngs.java
private void addShortcut() { Intent shortcutIntent = new Intent(getApplicationContext(), Settinngs.class); shortcutIntent.setAction(Intent.ACTION_MAIN); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "C.U.T Student"); //addIntent.putExtra("duplicate", false); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.logo)); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getApplicationContext().sendBroadcast(addIntent); }
From source file:io.github.runassudo.ptoffline.fragments.SettingsFragment.java
@Override public void onCreatePreferences(Bundle savedInstanceState, String s) { // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); TransportNetwork network = Preferences.getTransportNetwork(getActivity()); // Fill in current home location if available network_pref = findPreference("pref_key_network"); if (network != null) network_pref.setSummary(network.getName()); network_pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override/*from w ww . jav a2s.co m*/ public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(getActivity(), PickNetworkProviderActivity.class); // View view = preference.getView(null, null); View view = getView(); if (view != null) view = view.findFocus(); ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(view, (int) view.getX(), (int) view.getY(), 0, 0); ActivityCompat.startActivityForResult(getActivity(), intent, MainActivity.CHANGED_NETWORK_PROVIDER, options.toBundle()); return true; } }); home = findPreference("pref_key_home"); home.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // show home picker dialog HomePickerDialogFragment setHomeFragment = HomePickerDialogFragment.newInstance(); setHomeFragment.setOnHomeChangedListener(SettingsFragment.this); FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); setHomeFragment.show(ft, HomePickerDialogFragment.TAG); return true; } }); // Fill in current home location if available if (network != null) setHome(null); quickhome = findPreference("pref_key_create_quickhome_shortcut"); quickhome.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // create launcher shortcut Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, TransportrUtils.getShortcutIntent(getContext())); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.widget_name_quickhome)); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getContext(), R.drawable.ic_quickhome_widget)); addIntent.putExtra("duplicate", false); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getContext().sendBroadcast(addIntent); // switch to home-screen to let the user see the new shortcut Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain); return true; } }); }
From source file:de.grobox.liberario.settings.SettingsFragment.java
@Override public void onCreatePreferences(Bundle savedInstanceState, String s) { // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); TransportNetwork network = Preferences.getTransportNetwork(getActivity()); // Fill in current home location if available network_pref = findPreference("pref_key_network"); if (network != null) network_pref.setSummary(network.getName(getContext())); network_pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override/*from w ww.j a v a 2 s . co m*/ public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(getActivity(), PickTransportNetworkActivity.class); View view = getView(); if (view != null) view = view.findFocus(); ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(view, (int) view.getX(), (int) view.getY(), 0, 0); ActivityCompat.startActivityForResult(getActivity(), intent, REQUEST_NETWORK_PROVIDER_CHANGE, options.toBundle()); return true; } }); // TODO remove from here home = findPreference("pref_key_home"); home.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // show home picker dialog HomePickerDialogFragment setHomeFragment = HomePickerDialogFragment.newInstance(); FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); setHomeFragment.show(ft, HomePickerDialogFragment.TAG); return true; } }); // Fill in current home location if available if (network != null) setHome(null); quickhome = findPreference("pref_key_create_quickhome_shortcut"); quickhome.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // create launcher shortcut Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, TransportrUtils.getShortcutIntent(getContext())); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.widget_name_quickhome)); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getContext(), R.drawable.ic_quickhome_widget)); addIntent.putExtra("duplicate", false); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getContext().sendBroadcast(addIntent); // switch to home-screen to let the user see the new shortcut Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain); return true; } }); }