List of usage examples for android.content Intent EXTRA_SHORTCUT_ICON
String EXTRA_SHORTCUT_ICON
To view the source code for android.content Intent EXTRA_SHORTCUT_ICON.
Click Source Link
From source file:Main.java
public static void installLaunchShortCut(Context context, Intent intent, String shortCutName, Bitmap icon, boolean duplicate) { Intent shortCutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortCutName); shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); shortCutIntent.putExtra("duplicate", duplicate); intent.setAction(Intent.ACTION_MAIN); shortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); context.sendBroadcast(shortCutIntent); }
From source file:Main.java
/** * Creates an intent that will add a shortcut to the home screen. * @param title Title of the shortcut./* ww w. ja v a 2s.c o m*/ * @param icon Image that represents the shortcut. * @param shortcutIntent Intent to fire when the shortcut is activated. * @return Intent for the shortcut. */ public static Intent createAddToHomeIntent(String title, Bitmap icon, Intent shortcutIntent) { Intent i = new Intent(INSTALL_SHORTCUT); i.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); i.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); i.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); return i; }
From source file:com.sonetel.plugins.sonetelcallthru.CallThru.java
@Override public void onReceive(final Context context, Intent intent) { if (SipManager.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { // Retrieve and cache infos from the phone app if (!sPhoneAppInfoLoaded) { Resources r = context.getResources(); BitmapDrawable drawable = (BitmapDrawable) r.getDrawable(R.drawable.ic_wizard_sonetel); sPhoneAppBmp = drawable.getBitmap(); sPhoneAppInfoLoaded = true;/* www. j av a 2s . c o m*/ } Bundle results = getResultExtras(true); //if(pendingIntent != null) { // results.putParcelable(CallHandlerPlugin.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); //} results.putString(Intent.EXTRA_TITLE, "Call thru");// context.getResources().getString(R.string.use_pstn)); if (sPhoneAppBmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, sPhoneAppBmp); } if (intent.getStringExtra(Intent.EXTRA_TEXT) == null) return; //final PendingIntent pendingIntent = null; final String callthrunum = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); final String dialledNum = intent.getStringExtra(Intent.EXTRA_TEXT); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (callthrunum != null && PhoneCapabilityTester.isPhone(context)) { if (!callthrunum.equalsIgnoreCase("")) { DBAdapter dbAdapt = new DBAdapter(context); // Build pending intent SipAccount = dbAdapt.getAccount(1); if (SipAccount != null) { Intent i = new Intent(Intent.ACTION_CALL); i.setData(Uri.fromParts("tel", callthrunum, null)); final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); NetWorkThread = new Thread() { public void run() { SendMsgToNetWork(dialledNum, context, pendingIntent); }; }; NetWorkThread.start(); } if (!dialledNum.equalsIgnoreCase("")) { SipCallSessionImpl callInfo = new SipCallSessionImpl(); callInfo.setRemoteContact(dialledNum); callInfo.setIncoming(false); callInfo.callStart = System.currentTimeMillis(); callInfo.setAccId(3); //callInfo.setLastStatusCode(pjsua.PJ_SUCCESS); ContentValues cv = CallLogHelper.logValuesForCall(context, callInfo, callInfo.callStart); context.getContentResolver().insert(SipManager.CALLLOG_URI, cv); } } else { Location_Finder LocFinder = new Location_Finder(context); if (LocFinder.getContryName().startsWith("your")) Toast.makeText(context, "Country of your current location unknown. Call thru not available.", Toast.LENGTH_LONG).show(); else Toast.makeText(context, "No Call thru access number available in " + LocFinder.getContryName(), Toast.LENGTH_LONG).show(); //Toast.makeText(context, "No Call thru access number available in ", Toast.LENGTH_LONG).show(); } } // This will exclude next time tel:xxx is raised from csipsimple treatment which is wanted results.putString(Intent.EXTRA_PHONE_NUMBER, callthrunum); } }
From source file:com.sonetel.plugins.sonetelcallback.CallBack.java
@Override public void onReceive(final Context context, Intent intent) { if (SipManager.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { // Retrieve and cache infos from the phone app if (!sPhoneAppInfoLoaded) { Resources r = context.getResources(); BitmapDrawable drawable = (BitmapDrawable) r.getDrawable(R.drawable.ic_wizard_sonetel); sPhoneAppBmp = drawable.getBitmap(); sPhoneAppInfoLoaded = true;/* w w w . j av a 2 s. c om*/ } Bundle results = getResultExtras(true); //if(pendingIntent != null) { // results.putParcelable(CallHandlerPlugin.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); //} results.putString(Intent.EXTRA_TITLE, "Call back");// context.getResources().getString(R.string.use_pstn)); if (sPhoneAppBmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, sPhoneAppBmp); } if (intent.getStringExtra(Intent.EXTRA_TEXT) == null) return; final String dialledNum = intent.getStringExtra(Intent.EXTRA_TEXT); final String callthrunum = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); DBAdapter dbAdapt = new DBAdapter(context); // Build pending intent SipAccount = dbAdapt.getAccount(1); if (SipAccount != null) { //Intent i = new Intent(Intent.ACTION_CALL); //i.setData(Uri.fromParts("tel", callthrunum, null)); //final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); NetWorkThread = new Thread() { public void run() { SendMsgToNetWork(dialledNum, callthrunum, context, null); }; }; NetWorkThread.start(); } else if (SipAccount.acc_id != "1") Toast.makeText(context, "Unable to find Sonetel account. Please sign in using your Sonetel account", Toast.LENGTH_LONG).show(); if (!dialledNum.equalsIgnoreCase("")) { SipCallSessionImpl callInfo = new SipCallSessionImpl(); callInfo.setRemoteContact(dialledNum); callInfo.setIncoming(false); callInfo.callStart = System.currentTimeMillis(); callInfo.setAccId(4); //callInfo.setLastStatusCode(pjsua.PJ_SUCCESS); ContentValues cv = CallLogHelper.logValuesForCall(context, callInfo, callInfo.callStart); context.getContentResolver().insert(SipManager.CALLLOG_URI, cv); } //} //else //{ //} } // This will exclude next time tel:xxx is raised from csipsimple treatment which is wanted //results.putString(Intent.EXTRA_PHONE_NUMBER, callthrunum); }
From source file:com.csipsimple.plugins.twvoip.CallHandler.java
@Override public void onReceive(Context context, Intent intent) { if (ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { PendingIntent pendingIntent = null; // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_12VOIP_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_12VOIP_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_12VOIP_NBR, ""); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (!TextUtils.isEmpty(number) && !TextUtils.isEmpty(user) && !TextUtils.isEmpty(nbr) && !TextUtils.isEmpty(pwd)) { // Build pending intent Intent i = new Intent(ACTION_DO_TWVOIP_CALL); i.setClass(context, getClass()); i.putExtra(Intent.EXTRA_PHONE_NUMBER, number); pendingIntent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); // = PendingIntent.getActivity(context, 0, i, 0); }/* w w w .jav a2s . com*/ // Build icon Bitmap bmp = null; Drawable icon = context.getResources().getDrawable(R.drawable.icon); BitmapDrawable bd = ((BitmapDrawable) icon); bmp = bd.getBitmap(); // Build the result for the row (label, icon, pending intent, and // excluded phone number) Bundle results = getResultExtras(true); if (pendingIntent != null) { results.putParcelable(Intent.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); } results.putString(Intent.EXTRA_TITLE, "12voip WebCallback"); if (bmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, bmp); } // DO *NOT* exclude from next tel: intent cause we use a http method // results.putString(Intent.EXTRA_PHONE_NUMBER, number); } else if (ACTION_DO_TWVOIP_CALL.equals(intent.getAction())) { // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_12VOIP_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_12VOIP_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_12VOIP_NBR, ""); // params List<NameValuePair> params = new LinkedList<NameValuePair>(); params.add(new BasicNameValuePair("username", user)); params.add(new BasicNameValuePair("password", pwd)); params.add(new BasicNameValuePair("from", nbr)); params.add(new BasicNameValuePair("to", number)); String paramString = URLEncodedUtils.format(params, "utf-8"); String requestURL = "https://www.12voip.com//myaccount/makecall.php?" + paramString; HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(requestURL); // Create a response handler HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpGet); Log.d(THIS_FILE, "response code is " + httpResponse.getStatusLine().getStatusCode()); if (httpResponse.getStatusLine().getStatusCode() == 200) { InputStreamReader isr = new InputStreamReader(httpResponse.getEntity().getContent()); BufferedReader br = new BufferedReader(isr); String line; String fullReply = ""; boolean foundSuccess = false; while ((line = br.readLine()) != null) { if (!TextUtils.isEmpty(line) && line.toLowerCase().contains("success")) { showToaster(context, "Success... wait a while you'll called back"); foundSuccess = true; break; } if (!TextUtils.isEmpty(line)) { fullReply = fullReply.concat(line); } } if (!foundSuccess) { showToaster(context, "Error : server error : " + fullReply); } } else { showToaster(context, "Error : invalid request " + httpResponse.getStatusLine().getStatusCode()); } } catch (ClientProtocolException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } catch (IOException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } } }
From source file:com.csipsimple.plugins.betamax.CallHandlerWeb.java
@Override public void onReceive(Context context, Intent intent) { if (Utils.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { PendingIntent pendingIntent = null; // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_TW_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_TW_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_TW_NBR, ""); String provider = prefs.getString(CallHandlerConfig.KEY_TW_PROVIDER, ""); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (!TextUtils.isEmpty(number) && !TextUtils.isEmpty(user) && !TextUtils.isEmpty(nbr) && !TextUtils.isEmpty(pwd) && !TextUtils.isEmpty(provider)) { // Build pending intent Intent i = new Intent(ACTION_DO_WEB_CALL); i.setClass(context, getClass()); i.putExtra(Intent.EXTRA_PHONE_NUMBER, number); pendingIntent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); }//ww w . ja v a2s .c om // Build icon Bitmap bmp = Utils.getBitmapFromResource(context, R.drawable.icon_web); // Build the result for the row (label, icon, pending intent, and // excluded phone number) Bundle results = getResultExtras(true); if (pendingIntent != null) { results.putParcelable(Utils.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); } // Text for the row String providerName = ""; Resources r = context.getResources(); if (!TextUtils.isEmpty(provider)) { String[] arr = r.getStringArray(R.array.provider_values); String[] arrEntries = r.getStringArray(R.array.provider_entries); int i = 0; for (String prov : arr) { if (prov.equalsIgnoreCase(provider)) { providerName = arrEntries[i]; break; } i++; } } results.putString(Intent.EXTRA_TITLE, providerName + " " + r.getString(R.string.web_callback)); Log.d(THIS_FILE, "icon is " + bmp); if (bmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, bmp); } // DO *NOT* exclude from next tel: intent cause we use a http method // results.putString(Intent.EXTRA_PHONE_NUMBER, number); } else if (ACTION_DO_WEB_CALL.equals(intent.getAction())) { // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_TW_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_TW_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_TW_NBR, ""); String provider = prefs.getString(CallHandlerConfig.KEY_TW_PROVIDER, ""); // params List<NameValuePair> params = new LinkedList<NameValuePair>(); params.add(new BasicNameValuePair("username", user)); params.add(new BasicNameValuePair("password", pwd)); params.add(new BasicNameValuePair("from", nbr)); params.add(new BasicNameValuePair("to", number)); String paramString = URLEncodedUtils.format(params, "utf-8"); String requestURL = "https://www." + provider + "/myaccount/makecall.php?" + paramString; HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(requestURL); // Create a response handler HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpGet); Log.d(THIS_FILE, "response code is " + httpResponse.getStatusLine().getStatusCode()); if (httpResponse.getStatusLine().getStatusCode() == 200) { InputStreamReader isr = new InputStreamReader(httpResponse.getEntity().getContent()); BufferedReader br = new BufferedReader(isr); String line; String fullReply = ""; boolean foundSuccess = false; while ((line = br.readLine()) != null) { if (!TextUtils.isEmpty(line) && line.toLowerCase().contains("success")) { showToaster(context, "Success... wait a while you'll called back"); foundSuccess = true; break; } if (!TextUtils.isEmpty(line)) { fullReply = fullReply.concat(line); } } if (!foundSuccess) { showToaster(context, "Error : server error : " + fullReply); } } else { showToaster(context, "Error : invalid request " + httpResponse.getStatusLine().getStatusCode()); } } catch (ClientProtocolException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } catch (IOException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } } }
From source file:net.naonedbus.card.impl.HoraireCard.java
@Override protected Intent getMoreIntent() { final Intent intent = new Intent(getContext(), HorairesActivity.class); intent.putExtra(HorairesActivity.PARAM_ARRET, mArret); intent.putExtra(Intent.EXTRA_TITLE, R.string.card_more_horaires); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, R.drawable.ic_card_list); return intent; }
From source file:com.andernity.launcher2.InstallShortcutReceiver.java
private static ArrayList<PendingInstallShortcutInfo> getAndClearInstallQueue(SharedPreferences sharedPrefs) { synchronized (sLock) { Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null); if (strings == null) { return new ArrayList<PendingInstallShortcutInfo>(); }//from w w w . j a va2s.c o m ArrayList<PendingInstallShortcutInfo> infos = new ArrayList<PendingInstallShortcutInfo>(); for (String json : strings) { try { JSONObject object = (JSONObject) new JSONTokener(json).nextValue(); Intent data = Intent.parseUri(object.getString(DATA_INTENT_KEY), 0); Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); String name = object.getString(NAME_KEY); String iconBase64 = object.optString(ICON_KEY); String iconResourceName = object.optString(ICON_RESOURCE_NAME_KEY); String iconResourcePackageName = object.optString(ICON_RESOURCE_PACKAGE_NAME_KEY); if (iconBase64 != null && !iconBase64.isEmpty()) { byte[] iconArray = Base64.decode(iconBase64, Base64.DEFAULT); Bitmap b = BitmapFactory.decodeByteArray(iconArray, 0, iconArray.length); data.putExtra(Intent.EXTRA_SHORTCUT_ICON, b); } else if (iconResourceName != null && !iconResourceName.isEmpty()) { Intent.ShortcutIconResource iconResource = new Intent.ShortcutIconResource(); iconResource.resourceName = iconResourceName; iconResource.packageName = iconResourcePackageName; data.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); } data.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent); PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, launchIntent); infos.add(info); } catch (org.json.JSONException e) { Log.d("InstallShortcutReceiver", "Exception reading shortcut to add: " + e); } catch (java.net.URISyntaxException e) { Log.d("InstallShortcutReceiver", "Exception reading shortcut to add: " + e); } } sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>()).commit(); return infos; } }
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 {//from w w w. ja va 2 s. com 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:net.naonedbus.card.impl.CommentairesCard.java
@Override protected Intent getMoreIntent() { final ParamIntent intent = new ParamIntent(getContext(), CommentaireActivity.class); intent.putExtra(CommentaireActivity.PARAM_LIGNE, mLigne); intent.putExtra(CommentaireActivity.PARAM_SENS, mSens); intent.putExtra(CommentaireActivity.PARAM_ARRET, mArret); intent.putExtra(Intent.EXTRA_TITLE, R.string.card_more_commenter); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, R.drawable.ic_card_send); return intent; }