List of usage examples for android.net Uri fromParts
public static Uri fromParts(String scheme, String ssp, String fragment)
From source file:com.asksven.betterbatterystats.PackageFragmentActivity.java
public static void showInstalledAppDetails(Context context, String packageName) { Intent intent = new Intent(); final int apiLevel = Build.VERSION.SDK_INT; if (apiLevel >= 9) { // above 2.3 intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts(SCHEME, packageName, null); intent.setData(uri);//from w ww. j ava 2s .c om } else { // below 2.3 final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22 : APP_PKG_NAME_21); intent.setAction(Intent.ACTION_VIEW); intent.setClassName(APP_DETAILS_PACKAGE_NAME, APP_DETAILS_CLASS_NAME); intent.putExtra(appPkgName, packageName); } context.startActivity(intent); }
From source file:com.twolinessoftware.smarterlist.activity.BaseNavigationActivity.java
private void sendFeedbackEmail() { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "feedback@smarterlistapp.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.email_subject)); startActivity(Intent.createChooser(emailIntent, getString(R.string.email_send_text))); }
From source file:com.elkriefy.android.apps.chubbytabby.activity.MainActivity.java
private PendingIntent createPendingEmailIntent() { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "example@example.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); emailIntent.putExtra(Intent.EXTRA_TEXT, "Body"); return PendingIntent.getActivity(getApplicationContext(), 0, emailIntent, 0); }
From source file:org.adblockplus.android.AdblockPlus.java
/** * Opens Android application settings//from w w w .jav a 2 s . c o m */ public static void showAppDetails(Context context) { String packageName = context.getPackageName(); Intent intent = new Intent(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { // above 2.3 intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", packageName, null); intent.setData(uri); } else { // below 2.3 final String appPkgName = (Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO ? "pkg" : "com.android.settings.ApplicationPkgName"); intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra(appPkgName, packageName); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:edu.cwru.apo.Directory.java
public void onClick(View v) { switch (v.getId()) { case R.id.btnCall: Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + lastPhone)); startActivity(intent);/* w ww. ja v a 2 s. c o m*/ break; case R.id.btnText: startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", lastPhone, null))); break; default: String text = ((TextView) v).getText().toString(); int start = text.lastIndexOf('['); int end = text.lastIndexOf(']'); String caseID = text.substring(start + 1, end); Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, "_id = ?", new String[] { caseID }, null, null, null); if (results.getCount() != 1) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Error Loading Phone Number").setCancelable(false).setNeutralButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } else { results.moveToFirst(); phoneDialog = new Dialog(this); phoneDialog.setContentView(R.layout.phone_dialog); phoneDialog.setTitle(results.getString(0) + " " + results.getString(1)); TextView phoneText = (TextView) phoneDialog.findViewById((R.id.phoneText)); String phoneNumber = removeNonDigits(results.getString(3)); if (phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null")) { ((Button) phoneDialog.findViewById(R.id.btnCall)).setEnabled(false); ((Button) phoneDialog.findViewById(R.id.btnText)).setEnabled(false); phoneNumber = "not available"; } else { ((Button) phoneDialog.findViewById(R.id.btnCall)).setEnabled(true); ((Button) phoneDialog.findViewById(R.id.btnText)).setEnabled(true); ((Button) phoneDialog.findViewById(R.id.btnCall)).setOnClickListener(this); ((Button) phoneDialog.findViewById(R.id.btnText)).setOnClickListener(this); } lastPhone = phoneNumber; phoneText.setText("Phone Number: " + lastPhone); phoneDialog.show(); } break; } }
From source file:com.enadein.carlogbook.ui.AboutFragment.java
public void sendEmail(String subject) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getString(R.string.email), null)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); startActivity(Intent.createChooser(intent, "Send Email")); }
From source file:com.airg.android.permission.sample.MainActivity.java
private void gotoSettings() { final Intent intent; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getPackageName(), null)); } else {/* w w w . j a va 2 s . c o m*/ intent = new Intent(Intent.ACTION_VIEW); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra(Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO ? "pkg" : "com.android.settings.ApplicationPkgName", getPackageName()); } startActivityForResult(intent, REQUEST_SETTINGS); }
From source file:com.sonetel.plugins.sonetelcallthru.CallThru.java
@Override public void onReceive(final Context context, Intent intent) { if (SipManager.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { // Retrieve and cache infos from the phone app if (!sPhoneAppInfoLoaded) { Resources r = context.getResources(); BitmapDrawable drawable = (BitmapDrawable) r.getDrawable(R.drawable.ic_wizard_sonetel); sPhoneAppBmp = drawable.getBitmap(); sPhoneAppInfoLoaded = true;//from w ww . ja va2 s. c om } Bundle results = getResultExtras(true); //if(pendingIntent != null) { // results.putParcelable(CallHandlerPlugin.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); //} results.putString(Intent.EXTRA_TITLE, "Call thru");// context.getResources().getString(R.string.use_pstn)); if (sPhoneAppBmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, sPhoneAppBmp); } if (intent.getStringExtra(Intent.EXTRA_TEXT) == null) return; //final PendingIntent pendingIntent = null; final String callthrunum = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); final String dialledNum = intent.getStringExtra(Intent.EXTRA_TEXT); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (callthrunum != null && PhoneCapabilityTester.isPhone(context)) { if (!callthrunum.equalsIgnoreCase("")) { DBAdapter dbAdapt = new DBAdapter(context); // Build pending intent SipAccount = dbAdapt.getAccount(1); if (SipAccount != null) { Intent i = new Intent(Intent.ACTION_CALL); i.setData(Uri.fromParts("tel", callthrunum, null)); final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); NetWorkThread = new Thread() { public void run() { SendMsgToNetWork(dialledNum, context, pendingIntent); }; }; NetWorkThread.start(); } if (!dialledNum.equalsIgnoreCase("")) { SipCallSessionImpl callInfo = new SipCallSessionImpl(); callInfo.setRemoteContact(dialledNum); callInfo.setIncoming(false); callInfo.callStart = System.currentTimeMillis(); callInfo.setAccId(3); //callInfo.setLastStatusCode(pjsua.PJ_SUCCESS); ContentValues cv = CallLogHelper.logValuesForCall(context, callInfo, callInfo.callStart); context.getContentResolver().insert(SipManager.CALLLOG_URI, cv); } } else { Location_Finder LocFinder = new Location_Finder(context); if (LocFinder.getContryName().startsWith("your")) Toast.makeText(context, "Country of your current location unknown. Call thru not available.", Toast.LENGTH_LONG).show(); else Toast.makeText(context, "No Call thru access number available in " + LocFinder.getContryName(), Toast.LENGTH_LONG).show(); //Toast.makeText(context, "No Call thru access number available in ", Toast.LENGTH_LONG).show(); } } // This will exclude next time tel:xxx is raised from csipsimple treatment which is wanted results.putString(Intent.EXTRA_PHONE_NUMBER, callthrunum); } }
From source file:com.google.samples.apps.iosched.util.PermissionsUtils.java
private static Snackbar displayPermissionDeniedAppInfoResolutionSnackbar(@NonNull final Activity activity, final int messageResId, final boolean isPersistent) { View view = UIUtils.getRootView(activity); final int length = isPersistent ? Snackbar.LENGTH_INDEFINITE : Snackbar.LENGTH_LONG; Snackbar snackbar = Snackbar.make(view, messageResId, length).setAction(R.string.ok, new View.OnClickListener() { @Override//from ww w .j a v a2s . c om public void onClick(final View v) { LOGI(TAG, "Invoking App Info screen"); final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null); intent.setData(uri); activity.startActivity(intent); } }); snackbar.show(); return snackbar; }
From source file:de.dev.eth0.rssreader.app.ui.AbstractNavigationDrawerActivity.java
/** * Handles clicks on the navigation menu. * * @param menuItem/* w w w . j a va 2 s .co m*/ * @return */ @Override public boolean onNavigationItemSelected(final MenuItem menuItem) { // update highlighted item in the navigation menu final int itemId = menuItem.getItemId(); // allow some time after closing the drawer before performing real navigation // so the user can see what is happening drawerLayout.closeDrawers(); drawerActionHandler.postDelayed(new Runnable() { @Override public void run() { //Don't do anything if the item has already been selected if (getMenuItemId() != itemId) { switch (itemId) { case R.id.nav_summaries: startActivity(new Intent(AbstractNavigationDrawerActivity.this, MainActivity.class)); break; case R.id.nav_bookmarked: startActivity(new Intent(AbstractNavigationDrawerActivity.this, BookmarkedActivity.class)); break; case R.id.nav_authors: startActivity(new Intent(AbstractNavigationDrawerActivity.this, AuthorsActivity.class)); break; case R.id.nav_settings: startActivity(new Intent(AbstractNavigationDrawerActivity.this, SettingsActivity.class)); break; case R.id.nav_feedback: Intent email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", Constants.REPORT_EMAIL, null)); email.putExtra(Intent.EXTRA_SUBJECT, Constants.FEEDBACK_SUBJECT); startActivity(Intent.createChooser(email, null)); break; case R.id.nav_about: startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(BuildConfig.ABOUT_URL))); break; case R.id.nav_donate: //TODO: add bitcoin option startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(BuildConfig.DONATE_URL))); break; default: // ignore break; } } } }, DRAWER_CLOSE_DELAY_MS); return true; }