List of usage examples for android.net Uri encode
public static String encode(String s)
From source file:us.rader.wyfy.SavedRowsFragment.java
/** * Call {@link Activity#setResult(int, Intent)} and * {@link Activity#finish()}/*w w w.j a v a2 s . c o m*/ * * @param row * the data to pass back to the <code>Activity</code> that started * this one */ private void returnRowToCaller(Map<String, String> row) { FragmentActivity activity = getActivity(); if (row == null) { activity.setResult(Activity.RESULT_FIRST_USER); activity.finish(); return; } StringBuilder buffer = new StringBuilder("result"); //$NON-NLS-1$ buffer.append('?'); buffer.append(Uri.encode(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_HIDDEN)); buffer.append('='); buffer.append(Uri.encode(row.get(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_HIDDEN))); buffer.append('&'); buffer.append(Uri.encode(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_PASSWORD)); buffer.append('='); buffer.append(Uri.encode(row.get(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_PASSWORD))); buffer.append('&'); buffer.append(Uri.encode(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SECURITY)); buffer.append('='); buffer.append(Uri.encode(row.get(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SECURITY))); buffer.append('&'); buffer.append(Uri.encode(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SSID)); buffer.append('='); buffer.append(Uri.encode(row.get(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SSID))); Uri uri = Uri.parse(buffer.toString()); Intent intent = new Intent(); intent.setData(uri); activity.setResult(Activity.RESULT_OK, intent); activity.finish(); }
From source file:com.rp.podemu.SettingsActivity.java
public void sendDebug(View v) { String version;/*from w ww.j a v a 2s .c o m*/ try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); version = pInfo.versionName; } catch (PackageManager.NameNotFoundException e) { version = "NA"; } String username = "dev.roman"; String domain = "gmail.com"; String uriText = "mailto:" + username + "@" + domain + "?subject=" + Uri.encode("PodEmu debug - V" + version) + "&body=" + Uri.encode("You can put additional description of the problem instead of this text."); Uri uri = Uri.parse(uriText); Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(uri); //intent.setAction(Intent.ACTION_ATTACH_DATA); Uri attachment = Uri.parse("file://" + PodEmuLog.getLogFileName()); intent.putExtra(Intent.EXTRA_STREAM, attachment); try { startActivity(Intent.createChooser(intent, "Send email")); } catch (android.content.ActivityNotFoundException e) { new AlertDialog.Builder(this).setTitle("Application not found").setMessage( "There is no application installed that can send emails. Please go to Android Market and install one.") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // continue with delete } }).setIcon(android.R.drawable.ic_dialog_alert).show(); } }
From source file:com.zegoggles.smssync.CursorToMessage.java
public PersonRecord lookupPerson(final String address) { if (!mPeopleCache.containsKey(address)) { Uri personUri = Uri.withAppendedPath( NEW_CONTACT_API ? ECLAIR_CONTENT_FILTER_URI : Phones.CONTENT_FILTER_URL, Uri.encode(address)); Cursor c = mContext.getContentResolver().query(personUri, PHONE_PROJECTION, null, null, null); final PersonRecord record = new PersonRecord(); if (c != null && c.moveToFirst()) { record._id = c.getLong(c.getColumnIndex(PHONE_PROJECTION[0])); record.name = sanitize(c.getString(c.getColumnIndex(PHONE_PROJECTION[1]))); record.number = sanitize(//from w ww . j a v a 2s . c om NEW_CONTACT_API ? address : c.getString(c.getColumnIndex(PHONE_PROJECTION[2]))); record.email = getPrimaryEmail(record._id, record.number); } else { if (LOCAL_LOGV) Log.v(TAG, "Looked up unknown address: " + address); record.number = sanitize(address); record.email = getUnknownEmail(address); record.unknown = true; } mPeopleCache.put(address, record); if (c != null) c.close(); } return mPeopleCache.get(address); }
From source file:org.wso2.iot.agent.services.operation.OperationManager.java
/** * Retrieve device application information. * * @param operation - Operation object./*from ww w . j a v a 2s . c om*/ */ public void getApplicationList(org.wso2.iot.agent.beans.Operation operation) throws AndroidAgentException { ArrayList<DeviceAppInfo> apps = new ArrayList<>(appList.getInstalledApps().values()); JSONArray result = new JSONArray(); RuntimeInfo runtimeInfo = new RuntimeInfo(context); Map<String, Application> applications = runtimeInfo.getAppMemory(); for (DeviceAppInfo infoApp : apps) { JSONObject app = new JSONObject(); try { Application application = applications.get(infoApp.getPackagename()); app.put(APP_INFO_TAG_NAME, Uri.encode(infoApp.getAppname())); app.put(APP_INFO_TAG_PACKAGE, infoApp.getPackagename()); app.put(APP_INFO_TAG_VERSION, infoApp.getVersionName()); app.put(APP_INFO_TAG_SYSTEM, infoApp.isSystemApp()); app.put(APP_INFO_TAG_RUNNING, infoApp.isRunning()); if (application != null) { app.put(Constants.Device.USS, application.getUss()); } result.put(app); } catch (JSONException e) { operation.setStatus(resources.getString(R.string.operation_value_error)); operation.setOperationResponse("Error in parsing application list."); resultBuilder.build(operation); throw new AndroidAgentException("Invalid JSON format.", e); } } operation.setOperationResponse(result.toString()); operation.setStatus(resources.getString(R.string.operation_value_completed)); resultBuilder.build(operation); if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Application list sent"); } }
From source file:im.delight.android.commons.Social.java
/** * Whether the specified person is known on the current device or not * * @param context a context reference/*from w w w . j a v a 2s . c om*/ * @param phoneNumber the phone number to look up * @return whether the phone number is in the local address book or not */ public static boolean isPersonKnown(final Context context, final String phoneNumber) { try { final Uri phoneUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); final Cursor phoneEntries = context.getContentResolver().query(phoneUri, new String[] { android.provider.ContactsContract.PhoneLookup.DISPLAY_NAME }, null, null, null); return phoneEntries.getCount() > 0; } catch (Exception e) { return false; } }
From source file:appteam.nith.hillffair.activities.HomeActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from ww w .j av a2 s . c om*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id) { case R.id.profile: startActivity(new Intent(HomeActivity.this, ProfileActivity.class)); break; case R.id.settings: startActivity(new Intent(HomeActivity.this, SettingsActivity.class)); finish(); break; case R.id.aboutus: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format("%1$s", getString(R.string.app_name))); builder.setMessage(getResources().getText(R.string.aboutus_text)); builder.setPositiveButton("OK", null); builder.setIcon(R.drawable.ic_action_about); AlertDialog welcomeAlert = builder.create(); welcomeAlert.show(); break; case R.id.report: Intent intent = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode("appteam.nith@gmail.com") + "?subject=" + Uri.encode("Reporting A Bug/Feedback") + "&body=" + Uri.encode( "Hello, Appteam \nI want to report a bug/give feedback corresponding to the app Hillfair 2k16.\n.....\n\n-Your name"); Uri uri = Uri.parse(uriText); intent.setData(uri); startActivity(Intent.createChooser(intent, "Send Email")); break; case R.id.license: AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle(String.format("%1$s", getString(R.string.open_source_licenses))); CharSequence str = getResources().getText(R.string.licenses_text); builder2.setMessage(str); builder2.setPositiveButton("OK", null); AlertDialog welcomeAlert2 = builder2.create(); welcomeAlert2.show(); ((TextView) welcomeAlert2.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); break; case R.id.notification: startActivity(new Intent(HomeActivity.this, NotificationActivity.class)); break; case R.id.logout: pref.setUserId(null); pref.setRollNo(null); pref.setUserName(null); startActivity(new Intent(HomeActivity.this, LoginActivity.class)); finish(); break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:nl.dobots.imbusy.ImBusyApp.java
/** Retrieves the name as stored in the phones address book, given a phone number */ public String getContactName(String phoneNumber) { String[] projection = new String[] { ContactsContract.PhoneLookup.DISPLAY_NAME, ContactsContract.PhoneLookup._ID }; Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); Cursor cursor = getContentResolver().query(uri, projection, null, null, null); String contactName = ""; if (cursor != null) { if (cursor.moveToFirst()) { contactName = cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME)); }//from w w w .ja va 2 s . c o m cursor.close(); } return contactName; }
From source file:com.oscarsalguero.dialer.MainActivity.java
/** * Dials a phone number using the ACTION_DIAL intent (does not require permission). *///from w ww . j a v a 2 s. c o m private void dialPhone() { try { String phoneNumber = textViewDisplay.getText().toString(); Intent dialIntent = new Intent(Intent.ACTION_DIAL); dialIntent.setData(Uri.parse(URI_PREFIX_TEL + Uri.encode(phoneNumber))); dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dialIntent); logPhoneNumber(phoneNumber); } catch (Exception e) { Log.e(LOG_TAG, "An exception occurred trying to execute the DIAL intent.", e); } }
From source file:org.noise_planet.noisecapture.Results.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (record == null) { return false; }//w w w. j a v a 2 s . co m // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_result, menu); // Locate MenuItem with ShareActionProvider MenuItem item = menu.findItem(R.id.menu_item_share); // Fetch and store ShareActionProvider ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); Map<String, Storage.TagInfo> tagToIndex = new HashMap<>(Storage.TAGS_INFO.length); for (Storage.TagInfo sysTag : Storage.TAGS_INFO) { tagToIndex.put(sysTag.name, sysTag); } StringBuilder hashtags = new StringBuilder(); String[] localeStringArray = getResources().getStringArray(R.array.tags); for (String enTag : tags) { Storage.TagInfo tagInfo = tagToIndex.get(enTag); if (tagInfo != null && tagInfo.id < localeStringArray.length) { if (hashtags.length() > 0) { hashtags.append(","); } hashtags.append(localeStringArray[tagInfo.id].replace(" ", "")); } } if (record.getNoisePartyTag() != null && !record.getNoisePartyTag().isEmpty()) { hashtags.append(record.getNoisePartyTag()); } //@see https://dev.twitter.com/web/tweet-button/web-intent String url = "http://www.twitter.com/intent/tweet?via=Noise_Planet&hashtags=" + hashtags.toString() + "&text=" + Uri.encode(getString(R.string.share_message, record.getLeqMean())); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); if (mShareActionProvider == null) { mShareActionProvider = new ShareActionProvider(this); MenuItemCompat.setActionProvider(item, mShareActionProvider); } mShareActionProvider.setShareIntent(i); // Return true to display menu return true; }
From source file:org.wso2.emm.agent.services.operation.OperationManager.java
/** * Retrieve device application information. * * @param operation - Operation object.//from w ww . jav a 2 s . c om */ public void getApplicationList(org.wso2.emm.agent.beans.Operation operation) throws AndroidAgentException { ArrayList<DeviceAppInfo> apps = new ArrayList<>(appList.getInstalledApps().values()); JSONArray result = new JSONArray(); RuntimeInfo runtimeInfo = new RuntimeInfo(context); Map<String, Application> applications = runtimeInfo.getAppMemory(); for (DeviceAppInfo infoApp : apps) { JSONObject app = new JSONObject(); try { Application application = applications.get(infoApp.getPackagename()); app.put(APP_INFO_TAG_NAME, Uri.encode(infoApp.getAppname())); app.put(APP_INFO_TAG_PACKAGE, infoApp.getPackagename()); app.put(APP_INFO_TAG_VERSION, infoApp.getVersionName()); app.put(APP_INFO_TAG_SYSTEM, infoApp.isSystemApp()); app.put(APP_INFO_TAG_RUNNING, infoApp.isRunning()); if (application != null) { app.put(Constants.Device.USS, application.getUss()); } result.put(app); } catch (JSONException e) { operation.setStatus(resources.getString(R.string.operation_value_error)); operation.setOperationResponse("Error in parsing application list."); resultBuilder.build(operation); throw new AndroidAgentException("Invalid JSON format.", e); } } operation.setOperationResponse(result.toString()); operation.setStatus(resources.getString(R.string.operation_value_completed)); resultBuilder.build(operation); if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Application list sent"); } }