List of usage examples for android.net Uri encode
public static String encode(String s)
From source file:com.tweetlanes.android.core.urlservice.tweetmarker.TweetMarkerAPI.java
public static void getLastRead(AccountDescriptor account, final ConnectionStatus.Callbacks connectionStatus, final APICallback callback) { class TaskOutput { TaskOutput(TwitterFetchResult fetchResult, String response) { mFetchResult = fetchResult;//from www.j a v a 2 s . com mResponse = response; } TwitterFetchResult mFetchResult; String mResponse; } /* * */ AsyncTaskEx<AccountDescriptor, Void, TaskOutput> worker = new AsyncTaskEx<AccountDescriptor, Void, TaskOutput>() { @Override protected TaskOutput doInBackground(AccountDescriptor... inputArray) { String screenName = "chrismlacy";// inputArray[0]; String errorDescription = null; if (connectionStatus != null && !connectionStatus.isOnline()) { return new TaskOutput( new TwitterFetchResult(false, connectionStatus.getErrorMessageNoConnection()), null); } String url = String.format(BASE_URL + API_LAST_READ + "?api_key=%s&username=%s&collection=timeline", Uri.encode("TW-2C4324C62DF4"), Uri.encode(screenName)); HttpResponse response = getRequest(url, "freeForLife"); String jsonAsString = null; try { if (response != null) { jsonAsString = EntityUtils.toString(response.getEntity()); // JSONObject jsonObject = new JSONObject(jsonAsString); // success = jsonObject.getBoolean("success"); } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new TaskOutput(new TwitterFetchResult(errorDescription == null, errorDescription), jsonAsString); } @Override protected void onPostExecute(TaskOutput output) { if (callback != null) { callback.finished(output.mFetchResult, output.mResponse); } super.onPostExecute(output); } }; worker.execute(AsyncTaskEx.PRIORITY_HIGH, "Get TwMrkr Last Read", account); }
From source file:fr.masciulli.drinks.ui.activity.MainActivity.java
private void sendFeedback() { Intent sendIntent = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode(getString(R.string.feedback_mail)) + "?subject=" + Uri.encode(getString(R.string.feedback_default_subject)); Uri uri = Uri.parse(uriText);/*from ww w . j av a2 s .c o m*/ sendIntent.setData(uri); startActivity(Intent.createChooser(sendIntent, getString(R.string.action_feedback))); }
From source file:ch.pec0ra.mobilityratecalculator.DistanceCalculator.java
private String buildImageUrl() throws IOException, JSONException { String polyLines = getOverviewPolylines(); String ret = MapsDistances.BASE_MAP_URL; ret += MapsDistances.SIZE_OPTION + MapsDistances.WIDTH + MapsDistances.X + MapsDistances.HEIGHT; ret += MapsDistances.AND;//from www. j a v a2 s. c o m ret += MapsDistances.MAP_TYPE; ret += MapsDistances.AND; ret += MapsDistances.MARKERS_A + Uri.encode(from); ret += MapsDistances.AND; ret += MapsDistances.MARKERS_B + Uri.encode(to); ret += MapsDistances.AND; ret += MapsDistances.PATH + polyLines; ret += MapsDistances.AND; ret += MapsDistances.KEY + MapsDistances.staticMapKey; return ret; }
From source file:com.photbit.weatherse.app.ui.settings.AboutFragment.java
@Override public void contactClicked(String contactString) { Intent send = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode(contactString); Uri uri = Uri.parse(uriText);// w ww.ja v a2 s . co m send.setData(uri); startActivity(Intent.createChooser(send, "")); }
From source file:com.misczak.joinmybridge.CalendarFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri baseUri;//w w w. j a v a 2 s . c om if (mCurFilter != null) { baseUri = Uri.withAppendedPath(CalendarContract.Calendars.CONTENT_URI, Uri.encode(mCurFilter)); } else { baseUri = CalendarContract.Calendars.CONTENT_URI; } String select = "((" + CalendarContract.Calendars.CALENDAR_DISPLAY_NAME + " NOTNULL))"; return new CursorLoader(getActivity(), baseUri, CALENDARS_SUMMARY_PROJECTION, select, null, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME + " COLLATE LOCALIZED ASC"); }
From source file:com.github.rutvijkumar.imagesearch.api.google.GoogleImageProvider.java
protected String generateSearchURL(String keyword, int start) { return BASE_URL + "&" + params(start) + "&q=" + Uri.encode(keyword); }
From source file:com.magicmod.mmweather.engine.YahooWeatherProvider.java
@Override public List<LocationResult> getLocations(String input) { String language = getLanguage(); String params = "\"" + input + "\" and lang = \"" + language + "\""; String url = URL_LOCATION + Uri.encode(params); JSONObject jsonResults = fetchResults(url); if (jsonResults == null) { return null; }//from ww w . j a v a 2 s . c o m try { JSONArray places = jsonResults.optJSONArray("place"); if (places == null) { // Yahoo returns an object instead of an array when there's only one result places = new JSONArray(); places.put(jsonResults.getJSONObject("place")); } ArrayList<LocationResult> results = new ArrayList<LocationResult>(); for (int i = 0; i < places.length(); i++) { LocationResult result = parsePlace(places.getJSONObject(i)); if (result != null) { results.add(result); } } return results; } catch (JSONException e) { Log.e(TAG, "Received malformed places data (input=" + input + ", lang=" + language + ")", e); } return null; }
From source file:com.digiplex.extra.grantpermissiondemo.ContactsFragment.java
@Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { Uri baseUri;/*ww w .ja v a 2 s . c o m*/ if (mCurrentFilter != null) { baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(mCurrentFilter)); } else { baseUri = Contacts.CONTENT_URI; } String selection = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" + Contacts.HAS_PHONE_NUMBER + "=1) AND (" + Contacts.DISPLAY_NAME + " != '' ))"; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return new CursorLoader(getActivity(), baseUri, CONTACTS_SUMMARY_PROJECTION, selection, null, sortOrder); }
From source file:spit.matrix2017.Fragments.ContactUsFragment.java
@Nullable @Override//from w w w.j a v a 2 s. c om public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_contactus, container, false); findOnMap = (Button) view.findViewById(R.id.findOnMap); visitWebsite = (Button) view.findViewById(R.id.visitWebsite); contact_one_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_call_one); contact_two_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_call_two); save_one_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_save_one); save_two_Button = (AppCompatImageButton) view.findViewById(R.id.contact_us_save_two); emailId_matrix_TextView = (TextView) view.findViewById(R.id.emailId_matrix_TextView); emailId_matrix_TextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String to = "principal@spit.ac.in"; Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setType("text/plain"); intent.setData(Uri.parse("mailto:" + to)); intent.putExtra(Intent.EXTRA_EMAIL, to); try { startActivity(Intent.createChooser(intent, "Send Email")); } catch (Exception e) { Toast.makeText(getActivity(), e.getStackTrace().toString(), Toast.LENGTH_SHORT).show(); } } }); visitWebsite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.spit.ac.in"))); } }); findOnMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uri = Uri .parse("http://maps.google.com/maps?q=" + Uri.encode(getString(R.string.college_name))); Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri); mapIntent.setPackage("com.google.android.apps.maps"); try { startActivity(mapIntent); } catch (ActivityNotFoundException ex) { try { Intent newIntent = new Intent(Intent.ACTION_VIEW, uri); startActivity(newIntent); } catch (ActivityNotFoundException innerEx) { Toast.makeText(getContext(), "Please install a maps application", Toast.LENGTH_LONG).show(); } } } }); View.OnClickListener dialerOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_DIAL); switch (v.getId()) { case R.id.contact_us_call_one: intent.setData(Uri.parse("tel:" + "02226707440")); break; case R.id.contact_us_call_two: intent.setData(Uri.parse("tel:" + "02226287250")); break; } startActivity(intent); } }; contact_one_Button.setOnClickListener(dialerOnClickListener); contact_two_Button.setOnClickListener(dialerOnClickListener); View.OnClickListener saveOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI); switch (v.getId()) { case R.id.contact_us_save_one: intent.putExtra(ContactsContract.Intents.Insert.NAME, "S.P.I.T."); intent.putExtra(ContactsContract.Intents.Insert.PHONE, "02226707440"); break; case R.id.contact_us_save_two: intent.putExtra(ContactsContract.Intents.Insert.NAME, "S.P.I.T."); intent.putExtra(ContactsContract.Intents.Insert.PHONE, "02226708520"); break; } startActivity(intent); } }; save_one_Button.setOnClickListener(saveOnClickListener); save_two_Button.setOnClickListener(saveOnClickListener); return view; }