List of usage examples for android.net Uri getSchemeSpecificPart
public abstract String getSchemeSpecificPart();
From source file:Main.java
public static long alarmUriToId(Uri uri) { return Long.parseLong(uri.getSchemeSpecificPart()); }
From source file:Main.java
public static String getUriSafeString(Uri uri) { final String scheme = uri.getScheme(); final String ssp = uri.getSchemeSpecificPart(); if (scheme != null) { if (scheme.equalsIgnoreCase("tel") || scheme.equalsIgnoreCase("sip") || scheme.equalsIgnoreCase("sms") || scheme.equalsIgnoreCase("smsto") || scheme.equalsIgnoreCase("mailto")) { StringBuilder builder = new StringBuilder(64); builder.append(scheme);//from w ww. j a va2 s . c o m builder.append(':'); if (ssp != null) { for (int i = 0; i < ssp.length(); i++) { char c = ssp.charAt(i); if (c == '-' || c == '@' || c == '.') { builder.append(c); } else { builder.append('x'); } } } return builder.toString(); } } StringBuilder builder = new StringBuilder(64); if (scheme != null) { builder.append(scheme); builder.append(':'); } if (ssp != null) { builder.append(ssp); } return builder.toString(); }
From source file:com.forrestguice.suntimeswidget.LocationConfigView.java
public static Bundle bundleData(Uri data, String label) { String lat = ""; String lon = ""; if (data.getScheme().equals("geo")) { String dataString = data.getSchemeSpecificPart(); String[] dataParts = dataString.split(Pattern.quote("?")); if (dataParts.length > 0) { String geoPath = dataParts[0]; String[] geoParts = geoPath.split(Pattern.quote(",")); if (geoParts.length >= 2) { lat = geoParts[0];/*from ww w . j av a2s .com*/ lon = geoParts[1]; } } } Bundle bundle = new Bundle(); bundle.putString(KEY_DIALOGMODE, LocationViewMode.MODE_CUSTOM_ADD.name()); bundle.putString(KEY_LOCATION_MODE, WidgetSettings.LocationMode.CUSTOM_LOCATION.name()); bundle.putString(KEY_LOCATION_LATITUDE, lat); bundle.putString(KEY_LOCATION_LONGITUDE, lon); bundle.putString(KEY_LOCATION_LABEL, label); return bundle; }
From source file:be.e_contract.eid.android.BeIDBrowserActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.browser_view); setTitle(R.string.browser_app_name); Intent intent = getIntent();/* w w w. ja v a2s .c o m*/ Uri uri = intent.getData(); String endpoint = uri.getSchemeSpecificPart(); new GetTask().execute(endpoint); }
From source file:net.digitalfeed.pdroidalternative.intenthandler.PackageChangeHandler.java
@Override public void onReceive(Context context, Intent intent) { Log.d("PDroidAlternative", "PackageChangeHandler event received"); //Get the package name. If this fails, then the intent didn't contain the //essential data and should be ignored String packageName;//from ww w.j a v a 2 s . c om Uri inputUri = Uri.parse(intent.getDataString()); if (!inputUri.getScheme().equals("package")) { Log.d("PDroidAlternative", "Intent scheme was not 'package'"); return; } packageName = inputUri.getSchemeSpecificPart(); //If a package is being removed, we only want to delete the related //info it is not being updated/replaced by a newer version if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) { if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { Log.d("PDroidAlternative", "Triggering application deletion for package:" + packageName); DBInterface.getInstance(context).deleteApplicationRecord(packageName); } } else if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) { //If the package is just getting updated, then we only need to notify the user //if the permissions have changed if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { //TODO: check if the permissions have changed Log.d("PDroidAlternative", "PackageChangeHandler: App being replaced: " + packageName); Application oldApp = Application.fromDatabase(context, packageName); Application newApp = Application.fromPackageName(context, packageName); if (havePermissionsChanged(context, oldApp, newApp)) { //TODO: Handle permission change /* * This is an app for which the permissions have been updated, * so we need to update the database to include only correct permissions. * Maybe we should have some way of flagging new ones? */ newApp.setStatusFlags( (newApp.getStatusFlags() | oldApp.getStatusFlags() | Application.STATUS_FLAG_UPDATED) & ~Application.STATUS_FLAG_NEW); DBInterface.getInstance(context).updateApplicationRecord(newApp); displayNotification(context, NotificationType.update, packageName, DBInterface.getInstance(context).getApplicationLabel(packageName)); } } else { /* * This is a new app, not an app being replaced. We need to add it to the * database, then display a notification for it */ Log.d("PDroidAlternative", "PackageChangeHandler: New app added: " + packageName); /* * I'm not sure if we really want to be doing all this processing here, but * we do need to record a list of new/updated apps to write to the database * when the app next starts, or the intent is executed - or we do it now */ //get the application from the system, not from the database Application app = Application.fromPackageName(context, packageName); app.setStatusFlags(app.getStatusFlags() | Application.STATUS_FLAG_NEW); DBInterface.getInstance(context).addApplicationRecord(app); Log.d("PDroidAlternative", "PackageChangeHandler: New app record added: " + packageName); displayNotification(context, NotificationType.newinstall, packageName, app.getLabel()); Log.d("PDroidAlternative", "PackageChangeHandler: Notification presented: " + packageName); } } }
From source file:org.sufficientlysecure.keychain.ui.dialog.AddKeyserverDialogFragment.java
public void verifyConnection(String keyserver) { new AsyncTask<String, Void, FailureReason>() { ProgressDialog mProgressDialog;//from w w w .jav a 2 s .c o m String mKeyserver; @Override protected void onPreExecute() { mProgressDialog = new ProgressDialog(getActivity()); mProgressDialog.setMessage(getString(R.string.progress_verifying_keyserver_url)); mProgressDialog.setCancelable(false); mProgressDialog.show(); } @Override protected FailureReason doInBackground(String... keyservers) { mKeyserver = keyservers[0]; FailureReason reason = null; try { // replace hkps/hkp scheme and reconstruct Uri Uri keyserverUri = Uri.parse(mKeyserver); String scheme = keyserverUri.getScheme(); String schemeSpecificPart = keyserverUri.getSchemeSpecificPart(); String fragment = keyserverUri.getFragment(); if (scheme == null) throw new MalformedURLException(); if (scheme.equalsIgnoreCase("hkps")) scheme = "https"; else if (scheme.equalsIgnoreCase("hkp")) scheme = "http"; URI newKeyserver = new URI(scheme, schemeSpecificPart, fragment); Log.d("Converted URL", newKeyserver.toString()); TlsHelper.openConnection(newKeyserver.toURL()).getInputStream(); } catch (TlsHelper.TlsHelperException e) { reason = FailureReason.CONNECTION_FAILED; } catch (MalformedURLException e) { Log.w(Constants.TAG, "Invalid keyserver URL entered by user."); reason = FailureReason.INVALID_URL; } catch (URISyntaxException e) { Log.w(Constants.TAG, "Invalid keyserver URL entered by user."); reason = FailureReason.INVALID_URL; } catch (IOException e) { Log.w(Constants.TAG, "Could not connect to entered keyserver url"); reason = FailureReason.CONNECTION_FAILED; } return reason; } @Override protected void onPostExecute(FailureReason failureReason) { mProgressDialog.dismiss(); if (failureReason == null) { addKeyserver(mKeyserver, true); } else { verificationFailed(failureReason); } } }.execute(keyserver); }
From source file:com.kaliturin.blacklist.activities.MainActivity.java
private void showSendSMSActivity() { Uri uri = getIntent().getData(); if (uri == null) { return;// w w w . j a v a 2 s . c o m } // get phone number where to send the SMS String ssp = uri.getSchemeSpecificPart(); String number = ContactsAccessHelper.normalizePhoneNumber(ssp); if (number.isEmpty()) { return; } // find person by phone number in contacts String person = null; ContactsAccessHelper db = ContactsAccessHelper.getInstance(this); Contact contact = db.getContact(this, number); if (contact != null) { person = contact.name; } // get SMS thread id by phone number int threadId = db.getSMSThreadIdByNumber(this, number); if (threadId >= 0) { // get the count of unread sms of the thread int unreadCount = db.getSMSMessagesUnreadCountByThreadId(this, threadId); // open thread's SMS conversation activity Bundle arguments = new Bundle(); arguments.putInt(FragmentArguments.THREAD_ID, threadId); arguments.putInt(FragmentArguments.UNREAD_COUNT, unreadCount); arguments.putString(FragmentArguments.CONTACT_NUMBER, number); String title = (person != null ? person : number); CustomFragmentActivity.show(this, title, SMSConversationFragment.class, arguments); } // open SMS sending activity Bundle arguments = new Bundle(); arguments.putString(FragmentArguments.CONTACT_NAME, person); arguments.putString(FragmentArguments.CONTACT_NUMBER, number); String title = getString(R.string.New_message); CustomFragmentActivity.show(this, title, SMSSendFragment.class, arguments); }
From source file:edu.stanford.mobisocial.dungbeetle.HandleNfcContact.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();//from www . j a v a2 s.co m final Uri uri = intent.getData(); setContentView(R.layout.handle_give); Button saveButton = (Button) findViewById(R.id.save_contact_button); Button cancelButton = (Button) findViewById(R.id.cancel_button); Button mutualFriendsButton = (Button) findViewById(R.id.mutual_friends_button); mutualFriendsButton.setVisibility(View.GONE); if (uri != null && (uri.getScheme().equals(HomeActivity.SHARE_SCHEME) || uri.getSchemeSpecificPart().startsWith(FriendRequest.PREFIX_JOIN))) { mEmail = uri.getQueryParameter("email"); mName = uri.getQueryParameter("name"); if (mName == null) { mName = mEmail; } TextView nameView = (TextView) findViewById(R.id.name_text); nameView.setText("Would you like to be friends with " + mName + "?"); final long cid = FriendRequest.acceptFriendRequest(HandleNfcContact.this, uri, false); saveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { DBHelper helper = DBHelper.getGlobal(HandleNfcContact.this); IdentityProvider ident = new DBIdentityProvider(helper); try { JSONObject profile = new JSONObject(ident.userProfile()); byte[] data = FastBase64.decode(profile.getString("picture")); Helpers.updatePicture(HandleNfcContact.this, data); } catch (Exception e) { } // If asymmetric friend request, send public key. if (!NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { FriendRequest.sendFriendRequest(HandleNfcContact.this, cid, uri.getQueryParameter("cap")); } Toast.makeText(HandleNfcContact.this, "Added " + mName + " as a friend.", Toast.LENGTH_SHORT) .show(); finish(); } }); cancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Helpers.deleteContact(HandleNfcContact.this, cid); finish(); } }); ImageView portraitView = (ImageView) findViewById(R.id.image); if (uri != null) { /* ((App)getApplication()).contactImages.lazyLoadImage( mEmail.hashCode(), Gravatar.gravatarUri(mEmail, 100), portraitView); */ //((App)getApplication()).contactImages.lazyLoadImage(mPicture.hashCode(), mPicture, portraitView); } } else { saveButton.setEnabled(false); cancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); } }); Toast.makeText(this, "Failed to receive contact.", Toast.LENGTH_SHORT).show(); Log.d(TAG, "Failed to handle " + uri); } }
From source file:com.android.server.telecom.testapps.TestConnectionService.java
private void setAddress(Connection connection, Uri address) { connection.setAddress(address, TelecomManager.PRESENTATION_ALLOWED); if ("5551234".equals(address.getSchemeSpecificPart())) { connection.setCallerDisplayName("Hello World", TelecomManager.PRESENTATION_ALLOWED); }//from w ww. jav a 2 s. co m }
From source file:com.granita.icloudcalsync.resource.LocalCalendar.java
@SuppressLint("InlinedApi") protected Builder buildAttendee(Builder builder, Attendee attendee) { final Uri member = Uri.parse(attendee.getValue()); final String email = member.getSchemeSpecificPart(); final Cn cn = (Cn) attendee.getParameter(Parameter.CN); if (cn != null) builder.withValue(Attendees.ATTENDEE_NAME, cn.getValue()); int type = Attendees.TYPE_NONE; CuType cutype = (CuType) attendee.getParameter(Parameter.CUTYPE); if (cutype == CuType.RESOURCE) type = Attendees.TYPE_RESOURCE;//from w ww . j a v a 2s.co m else { Role role = (Role) attendee.getParameter(Parameter.ROLE); int relationship; if (role == Role.CHAIR) relationship = Attendees.RELATIONSHIP_ORGANIZER; else { relationship = Attendees.RELATIONSHIP_ATTENDEE; if (role == Role.OPT_PARTICIPANT) type = Attendees.TYPE_OPTIONAL; else if (role == Role.REQ_PARTICIPANT) type = Attendees.TYPE_REQUIRED; } builder.withValue(Attendees.ATTENDEE_RELATIONSHIP, relationship); } int status = Attendees.ATTENDEE_STATUS_NONE; PartStat partStat = (PartStat) attendee.getParameter(Parameter.PARTSTAT); if (partStat == null || partStat == PartStat.NEEDS_ACTION) status = Attendees.ATTENDEE_STATUS_INVITED; else if (partStat == PartStat.ACCEPTED) status = Attendees.ATTENDEE_STATUS_ACCEPTED; else if (partStat == PartStat.DECLINED) status = Attendees.ATTENDEE_STATUS_DECLINED; else if (partStat == PartStat.TENTATIVE) status = Attendees.ATTENDEE_STATUS_TENTATIVE; return builder.withValue(Attendees.ATTENDEE_EMAIL, email).withValue(Attendees.ATTENDEE_TYPE, type) .withValue(Attendees.ATTENDEE_STATUS, status); }