List of usage examples for android.net Uri encode
public static String encode(String s)
From source file:it.ms.theing.loquitur.functions.IntentInterface.java
/** * Set the data for the current intent// w w w . j ava 2 s. c o m * @param argument * is the first part of the data, usually a uri header, not encoded * @param rest * this part of the data is encoded in uri format */ @JavascriptInterface public void data(String argument, String rest) { try { if (rest.length() != 0) { argument += Uri.encode(rest); } intent.setData(Uri.parse(argument)); } catch (Exception e) { Utils.safe(e); } }
From source file:com.mindprotectionkit.freephone.contacts.ContactAccessor.java
public CursorLoader getFavoritesCursor(Context context, String filter) { Uri uri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(filter)); return getFavoritesCursor(context, uri); }
From source file:com.example.demo_dv_fuse.DetailsTab.java
@SuppressLint("DefaultLocale") void handleViewGoogleMap() { // TODO use airport lat/long here final double lat = 28.4294; final double lon = 81.3089; final int zoom = 14; final String label = "Orlando International Airport (MCO)"; //$NON-NLS-1$ final String query = Uri.encode(label); final String uri = String.format("geo:%f,%f?q=%s&z=%d&t=h", lat, lon, query, zoom); //$NON-NLS-1$ final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); startActivity(intent);//from w w w . ja v a2s. com }
From source file:ch.pec0ra.mobilityratecalculator.DistanceCalculator.java
private String buildDirectionsUrl() { String ret = MapsDistances.BASE_DIRECTIONS_URL; ret += MapsDistances.ORIGIN + Uri.encode(from); ret += MapsDistances.AND;/*from www . ja va 2 s .com*/ ret += MapsDistances.DESTINATION + Uri.encode(to); ret += MapsDistances.AND; ret += MapsDistances.KEY + MapsDistances.directionsKey; return ret; }
From source file:com.juick.android.ExploreActivity.java
public void onClick(View v) { String search = etSearch.getText().toString().trim(); if (search.length() == 0) { Toast.makeText(this, R.string.Enter_a_message, Toast.LENGTH_SHORT).show(); return;//from w ww . j a v a2s .c o m } if (search.startsWith("*")) { Intent i = new Intent(this, MessagesActivity.class); String tagg = Uri.encode(search.substring(1)); JuickCompatibleURLMessagesSource jms = new JuickCompatibleURLMessagesSource( getString(R.string.Tag) + ": " + search.substring(1), "search_tag", this); jms.setCanNext(false); jms.putArg("tag", tagg); if (uid > 0) { jms.putArg("user_id", "" + uid); } i.putExtra("messagesSource", jms); startActivity(i); } else if (search.startsWith("#")) { final String maybeJuickMessageIdStr = search.substring(1).trim(); try { final int mid = Integer.parseInt(maybeJuickMessageIdStr); Intent i = new Intent(this, ThreadActivity.class); i.putExtra("mid", JuickMessageID.fromString("" + mid)); i.putExtra("messagesSource", getIntent().getSerializableExtra("messagesSource")); startActivity(i); overridePendingTransition(R.anim.enter_slide_to_left, R.anim.leave_lower_and_dark); } catch (Exception ex) { Toast.makeText(getApplicationContext(), ex.toString(), Toast.LENGTH_SHORT).show(); } } else if (search.startsWith("@")) { final String maybeJuickUserId = search.substring(1).trim(); JuickMicroBlog.obtainProperUserIdByName(this, maybeJuickUserId, "Getting Juick User Id", new Utils.Function<Void, Pair<String, String>>() { @Override public Void apply(Pair<String, String> cred) { Intent i = new Intent(ExploreActivity.this, MessagesActivity.class); i.putExtra("messagesSource", new JuickCompatibleURLMessagesSource("@" + maybeJuickUserId, "direct_uid", ExploreActivity.this).putArg("user_id", cred.first)); startActivity(i); return null; //To change body of implemented methods use File | Settings | File Templates. } }); } else { Intent i = new Intent(this, MessagesActivity.class); JuickCompatibleURLMessagesSource jms = new JuickCompatibleURLMessagesSource( getString(R.string.Search) + ": " + search, "search", this); jms.setCanNext(false); if (uid > 0) { jms.putArg("user_id", "" + uid); } if (uname != null) { jms.putArg("uname", uname); } jms.putArg("search", Uri.encode(search)); i.putExtra("messagesSource", jms); startActivity(i); } }
From source file:com.innoc.secureline.contacts.ContactAccessor.java
public CursorLoader getRegisteredFavoritesCursor(Context context, String filter) { Uri uri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(filter)); return getRegisteredFavoritesCursor(context, uri); }
From source file:org.thoughtcrime.securesms.contacts.ContactAccessorNewApi.java
@Override public List<String> getNumbersForThreadSearchFilter(String constraint, ContentResolver contentResolver) { LinkedList<String> numberList = new LinkedList<String>(); Cursor cursor = null;/*from w ww .ja v a 2 s. c o m*/ try { cursor = contentResolver.query(Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(constraint)), null, null, null, null); while (cursor != null && cursor.moveToNext()) numberList.add(cursor.getString(cursor.getColumnIndexOrThrow(Phone.NUMBER))); } finally { if (cursor != null) cursor.close(); } return numberList; }
From source file:com.appnexus.opensdk.PBImplementation.java
private static void sendBroadcast(Context context, String auctionInfo, byte[] imageBytes) { String dataUrl = URL_BROADCAST_PREFIX + Uri.encode(auctionInfo); Intent intent = new Intent(ACTION_BROADCAST, Uri.parse(dataUrl)); intent.putExtra(KEY_IMAGE, imageBytes); context.sendBroadcast(intent);//from w w w.j a v a 2 s. c om }
From source file:com.securecomcode.voice.contacts.ContactsCursorLoader.java
private Cursor queryAndroidDb(String filter) { Uri baseUri;/*ww w .j a va 2 s . c om*/ Cursor cursor; List<Cursor> cursors = new ArrayList<Cursor>(); if (filter != null) { baseUri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Phone.CONTENT_FILTER_URI, Uri.encode(filter)); cursor = context.getContentResolver().query(baseUri, null, null, null, CONTACT_LIST_SORT); cursors.add(cursor); baseUri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Email.CONTENT_FILTER_URI, Uri.encode(filter)); cursor = context.getContentResolver().query(baseUri, null, null, null, CONTACT_LIST_SORT); cursors.add(cursor); return new MergeCursor(cursors.toArray(new Cursor[] {})); } else { baseUri = ContactsContract.Data.CONTENT_URI; cursor = context.getContentResolver().query(baseUri, null, ContactsContract.Data.IN_VISIBLE_GROUP + "!=0 AND (" + ContactsContract.Data.MIMETYPE + "=? OR " + ContactsContract.Data.MIMETYPE + "=?)", new String[] { ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE }, CONTACT_LIST_SORT); return cursor; } }
From source file:com.appnexus.opensdk.InstallTrackerPixel.java
private String getInstallUrl(String params) { String appid = null;//from w w w .j ava2s . c o m String hidmd5 = null; String hidsha1 = null; if (context != null) { appid = context.getApplicationContext().getPackageName(); String aid = android.provider.Settings.Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); // Get hidmd5, hidsha1, the devide ID hashed hidmd5 = HashingFunctions.md5(aid); hidsha1 = HashingFunctions.sha1(aid); } StringBuilder urlBuilder = new StringBuilder(Settings.getSettings().INSTALL_BASE_URL); urlBuilder.append(pid != null && !pid.equals("") ? "&id=" + Uri.encode(pid) : ""); urlBuilder.append(params != null ? "&" + params : ""); urlBuilder.append(appid != null ? "&appid=" + Uri.encode(appid) : ""); urlBuilder.append(hidmd5 != null ? "&md5udid=" + Uri.encode(hidmd5) : ""); urlBuilder.append(hidsha1 != null ? "&sha1udid=" + Uri.encode(hidmd5) : ""); return urlBuilder.toString(); }