List of usage examples for android.net Uri encode
public static String encode(String s)
From source file:com.oliversride.wordryo.Utils.java
public static String phoneToContact(Context context, String phone, boolean phoneStandsIn) { // I'm assuming that since context is passed this needn't // worry about synchronization -- will always be called from // UI thread. String name;//from w w w .j a v a 2s. co m synchronized (s_phonesHash) { if (s_phonesHash.containsKey(phone)) { name = s_phonesHash.get(phone); } else { name = null; ContentResolver contentResolver = context.getContentResolver(); Cursor cursor = contentResolver.query( Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phone)), new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null); if (cursor.moveToNext()) { int indx = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME); name = cursor.getString(indx); } cursor.close(); s_phonesHash.put(phone, name); } } if (null == name && phoneStandsIn) { name = phone; } return name; }
From source file:gov.wa.wsdot.android.wsdot.ui.TravelTimesFragment.java
public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] projection = { TravelTimes._ID, TravelTimes.TRAVEL_TIMES_ID, TravelTimes.TRAVEL_TIMES_TITLE, TravelTimes.TRAVEL_TIMES_UPDATED, TravelTimes.TRAVEL_TIMES_DISTANCE, TravelTimes.TRAVEL_TIMES_AVERAGE, TravelTimes.TRAVEL_TIMES_CURRENT, TravelTimes.TRAVEL_TIMES_IS_STARRED }; Uri baseUri;/*from w w w.ja v a 2s . c om*/ if (mFilter != null) { baseUri = Uri.withAppendedPath(TravelTimes.CONTENT_FILTER_URI, Uri.encode(mFilter)); } else { baseUri = TravelTimes.CONTENT_URI; } CursorLoader cursorLoader = new TravelTimesItemsLoader(getActivity(), baseUri, projection, null, null, null); return cursorLoader; }
From source file:it.gmariotti.android.examples.googleaccount.SmsBackupGDriveActivity.java
private Cursor tryOpenContactsCursorByAddress(String phoneNumber) { try {//ww w . j av a2s. c o m return getContentResolver().query(ContactsContract.PhoneLookup.CONTENT_FILTER_URI.buildUpon() .appendPath(Uri.encode(phoneNumber)).build(), ContactsQuery.PROJECTION, null, null, null); } catch (Exception e) { // Can be called by the content provider // java.lang.IllegalArgumentException: URI: // content://com.android.contacts/phone_lookup/ Log.w(TAG, "Error looking up contact name", e); return null; } }
From source file:com.haibison.android.anhuu.utils.ui.history.HistoryFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (BuildConfig.DEBUG) Log.d(CLASSNAME, "onCreateLoader()"); enableControls(false);//from w w w . j a v a 2 s. c o m String selection = null; if (!TextUtils.isEmpty(mHistoryCursorAdapter.getSearchText())) { selection = DbUtils.rawSqlEscapeString(Uri.encode(mHistoryCursorAdapter.getSearchText().toString())); selection = String.format("%s LIKE '%%://%%%s%%'", HistoryContract.COLUMN_URI, selection); } if (id == mLoaderIdHistoryData) { mHandler.removeCallbacksAndMessages(null); mHandler.postDelayed(mViewLoadingShower, Display.DELAY_TIME_FOR_SIMPLE_ANIMATION); mHistoryCursorAdapter.changeCursor(null); /* * Offset. */ if (mCurrentPage >= mPageCount) mCurrentPage = mPageCount - 1; if (mCurrentPage < 0) mCurrentPage = 0; int offset = mCurrentPage * mMaxItemsPerPage; return new CursorLoader(getActivity(), HistoryContract.genContentUri(getActivity()), null, selection, null, String.format("%s DESC LIMIT %s OFFSET %s", HistoryContract.COLUMN_MODIFICATION_TIME, mMaxItemsPerPage, offset)); } // mLoaderIdHistoryData else if (id == mLoaderIdHistoryCounter) { mPageCount = 1; mCurrentPage = 0; if (mCursorCounter != null) { mCursorCounter.close(); mCursorCounter = null; } return new CursorLoader(getActivity(), HistoryContract.genContentUri(getActivity()), new String[] { HistoryContract._COUNT }, selection, null, null); } // mLoaderIdHistoryCounter return null; }
From source file:ir.rasen.charsoo.view.fragment.FragmentUserRegisterOfferFriendInvite.java
public static Intent createEmailIntent(final String[] toEmail, final String subject, final String message) { String emailsString = ""; if (toEmail.length > 0) emailsString = toEmail[0];/*from w w w.java 2s .c o m*/ for (int i = 1; i < toEmail.length; i++) { emailsString += ","; emailsString += toEmail[i]; } Intent sendTo = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode(emailsString) + "?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(message); Uri uri = Uri.parse(uriText); sendTo.setData(uri); List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(sendTo, 0); // Emulators may not like this check... if (!resolveInfos.isEmpty()) { return Intent.createChooser(sendTo, "Send Email"); } // Nothing resolves send to, so fallback to send... Intent send = new Intent(Intent.ACTION_SEND); send.setType("message/rfc822"); send.putExtra(Intent.EXTRA_EMAIL, toEmail); send.putExtra(Intent.EXTRA_SUBJECT, subject); send.putExtra(Intent.EXTRA_TEXT, message); return Intent.createChooser(send, "Send Email"); }
From source file:se.eliga.aves.birddetail.BirdDetailsTabActivity.java
protected String getGoogleImagesUrl(Bird bird) { return "https://www.google.com/search?tbm=isch&q=" + Uri.encode(bird.getLatinSpecies()) + "#rcnt, "; }
From source file:com.getchute.android.photopickerplus.ui.fragment.FragmentSingle.java
public void updateFragment(AccountModel account, String folderId, List<Integer> selectedItemsPositions) { this.account = account; this.selectedItemsPositions = selectedItemsPositions; this.folderId = folderId; String encodedId = Uri.encode(folderId); if (getActivity() != null) { GCAccounts.accountSingle(PhotoPickerPreferenceUtil.get().getAccountType().name().toLowerCase(), account.getShortcut(), encodedId, new AccountSingleCallback()).executeAsync(); }/*from ww w. j a va2 s. c o m*/ }
From source file:se.eliga.aves.birddetail.BirdDetailsTabActivity.java
protected String getYoutubeUrl(Bird bird) { return "https://www.youtube.com/results?search_query=" + Uri.encode(bird.getLatinSpecies()); }
From source file:com.geniusgithub.contact.contact.calllog.ContactInfoHelper.java
/** * Determines the contact information for the given SIP address. * <p>/* w w w .j a v a2 s .c o m*/ * It returns the contact info if found. * <p> * If no contact corresponds to the given SIP address, returns {@link ContactInfo#EMPTY}. * <p> * If the lookup fails for some other reason, it returns null. */ private ContactInfo queryContactInfoForSipAddress(String sipAddress) { final ContactInfo info; // "contactNumber" is a SIP address, so use the PhoneLookup table with the SIP parameter. Uri.Builder uriBuilder = PhoneLookup.CONTENT_FILTER_URI.buildUpon(); uriBuilder.appendPath(Uri.encode(sipAddress)); uriBuilder.appendQueryParameter(PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, "1"); return lookupContactFromUri(uriBuilder.build()); }
From source file:ti.modules.titanium.network.NetworkModule.java
@Kroll.method @Kroll.topLevel public String encodeURIComponent(String component) { return Uri.encode(component); }