List of usage examples for android.content Intent ACTION_SENDTO
String ACTION_SENDTO
To view the source code for android.content Intent ACTION_SENDTO.
Click Source Link
From source file:com.codebutler.farebot.activities.AdvancedCardInfoActivity.java
private void reportError() { DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override//from ww w .ja va2s .com public void onClick(DialogInterface dialog, int which) { StringBuilder builder = new StringBuilder(); builder.append(Utils.getDeviceInfoString()); builder.append("\n\n"); builder.append(mError.toString()); builder.append("\n"); builder.append(Utils.getErrorMessage(mError)); builder.append("\n"); for (StackTraceElement elem : mError.getStackTrace()) { builder.append(elem.toString()); builder.append("\n"); } builder.append("\n\n"); try { builder.append(Utils.xmlNodeToString(mCard.toXML().getOwnerDocument())); } catch (Exception ex) { builder.append("Failed to generate XML: "); builder.append(ex); } builder.append("\n\n"); builder.append(getString(R.string.comments)); builder.append(":\n\n"); Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:eric+farebot@codebutler.com")); intent.putExtra(Intent.EXTRA_SUBJECT, "FareBot Bug Report"); intent.putExtra(Intent.EXTRA_TEXT, builder.toString()); startActivity(intent); } }; new AlertDialog.Builder(this).setTitle(R.string.report_error_privacy_title) .setMessage(R.string.report_error_privacy_message).setPositiveButton(android.R.string.ok, listener) .setNegativeButton(android.R.string.cancel, null).show(); }
From source file:com.shareyourproxy.IntentLauncher.java
/** * Send SMS to phone number on Hangouts. * * @param activity context// www . ja va2s . c o m * @param actionAddress to contactId */ public static void launchHangoutsIntent(Activity activity, String actionAddress) { StringBuilder sb = new StringBuilder("content://com.android.contacts/data/").append(actionAddress); Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(sb.toString())); intent.setPackage("com.google.android.talk"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (intent.resolveActivity(activity.getPackageManager()) != null) { activity.startActivity(intent); } }
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];//www. ja va 2 s. co 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:com.xabber.android.ui.activity.ContactList.java
@Override public void onCreate(Bundle savedInstanceState) { if (Intent.ACTION_VIEW.equals(getIntent().getAction()) || Intent.ACTION_SEND.equals(getIntent().getAction()) || Intent.ACTION_SENDTO.equals(getIntent().getAction()) || Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) { ActivityManager.getInstance().startNewTask(this); }//from w w w .ja v a2s . c o m super.onCreate(savedInstanceState); if (isFinishing()) { return; } setContentView(R.layout.contact_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default); toolbar.setOnClickListener(this); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.application_title_short, R.string.application_title_short); drawerLayout.setDrawerListener(drawerToggle); toolbar.inflateMenu(R.menu.contact_list); optionsMenu = toolbar.getMenu(); setUpSearchView(optionsMenu); toolbar.setOnMenuItemClickListener(this); barPainter = new BarPainter(this, toolbar); barPainter.setDefaultColor(); toolbar.setTitle(R.string.application_title_full); if (savedInstanceState != null) { sendText = savedInstanceState.getString(SAVED_SEND_TEXT); action = savedInstanceState.getString(SAVED_ACTION); } else { getSupportFragmentManager().beginTransaction() .add(R.id.container, new ContactListFragment(), CONTACT_LIST_TAG).commit(); sendText = null; action = getIntent().getAction(); } getIntent().setAction(null); }
From source file:nuclei.ui.share.PackageTargetManager.java
/** * Create an intent with package specific modifications * * @param authority The file authority provider to be used for sharing files * @param permissionRequestCode Some packages may require we put files on external storage, * this is the permission request code that will be used to request that permission *//*from w ww. j a v a 2 s . co m*/ public Intent onCreateIntent(Activity activity, String authority, ResolveInfo info, int permissionRequestCode) { int maxLen = getMaxLen(info.activityInfo.packageName); String text = mText; if (maxLen != Integer.MAX_VALUE) text = trim(text, mUrl, maxLen); else if (mText != null && mUrl != null) text += '\n' + mUrl; Intent intent = new Intent( TextUtils.isEmpty(mEmail) && TextUtils.isEmpty(mSms) ? Intent.ACTION_SEND : Intent.ACTION_SENDTO); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setPackage(info.activityInfo.packageName); onSetDefault(activity, info.activityInfo.packageName, authority, intent, text); switch (info.activityInfo.packageName) { case FACEBOOK: intent = onFacebook(activity, intent); break; case WECHAT: intent = onExternalStorage(activity, info.activityInfo.packageName, authority, intent, permissionRequestCode, true); break; case LINE: case TELEGRAM: case WHATSAP: intent = onExternalStorage(activity, info.activityInfo.packageName, authority, intent, permissionRequestCode, false); break; case INSTAGRAM: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) intent = onExternalStorage(activity, info.activityInfo.packageName, authority, intent, permissionRequestCode, false); break; } return intent; }
From source file:id.zelory.codepolitan.ui.ReadActivity.java
private void onShareArticle(String packageName) { Article article = articles.get(position); if ("more".equals(packageName)) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, Html.fromHtml(article.getTitle())); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(article.getTitle()) + "\n" + article.getLink()); startActivity(Intent.createChooser(intent, "Share")); } else if ("email".equals(packageName)) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_SUBJECT, Html.fromHtml(article.getTitle())); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(article.getTitle()) + "\n" + article.getLink()); startActivity(intent);//from w w w . j a v a2 s . co m } else if ("sms".equals(packageName)) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("smsto:")); intent.putExtra(Intent.EXTRA_SUBJECT, Html.fromHtml(article.getTitle())); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(article.getTitle()) + "\n" + article.getLink()); startActivity(intent); } else { boolean shared = false; Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, Html.fromHtml(article.getTitle())); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(article.getTitle()) + "\n" + article.getLink()); for (ResolveInfo resolveInfo : getPackageManager().queryIntentActivities(intent, 0)) { if (packageName.equals(resolveInfo.activityInfo.packageName)) { intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setComponent(new ComponentName(packageName, resolveInfo.activityInfo.name)); startActivity(intent); shared = true; break; } } if (!shared) { openPlayStore(packageName); } } }
From source file:org.shaastra.helper.SuperAwesomeCardFragment2.java
@SuppressLint("NewApi") @Override//ww w . j av a 2s. c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); ListView lv; EditText inputSearch; FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); //v.setBackgroundResource(R.drawable.background_card); v.setText("CARD " + (position + 1)); View v1 = inflater.inflate(R.layout.contacts_list, container, false); lv = (ListView) v1.findViewById(R.id.list1); inputSearch = (EditText) v1.findViewById(R.id.inputSearch); ArrayList<Coord> rowItems = new ArrayList<Coord>(); if (position == 0) for (int i = 0; i < con.size(); i++) { Coord item = new Coord(con.get(i), pon.get(i), eon.get(i), eson.get(i)); rowItems.add(item); } else { for (int i = 0; i < len[position]; i++) { Coord item = new Coord(cString[position][i], pString[position][i], eString[position][i], evString[position][i]); rowItems.add(item); } } /*final ArrayAdapter<String> files = new ArrayAdapter<String>(getActivity(), R.layout.custom_list_item ); files.addAll(values); */ final CoordAdapter files = new CoordAdapter(getActivity(), R.layout.cordlist, rowItems); v1.setBackgroundColor(0xbba0d9ea); lv.setAdapter(files); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { b1 = new AlertDialog.Builder(getActivity()); b1.setMessage("What do you want to do?"); b1.setNegativeButton("Call", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub TextView t = (TextView) view.findViewById(R.id.cordphone); String url = "tel:" + t.getText(); Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); startActivity(intent); } }); b1.setPositiveButton("Message", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub TextView t = (TextView) view.findViewById(R.id.cordphone); String url = "sms:" + t.getText(); Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(url)); startActivity(intent); } }); AlertDialog a1 = b1.create(); a1.setCanceledOnTouchOutside(true); a1.show(); //Open the browser here } }); inputSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text files.getFilter().filter(cs.toString()); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } }); //v1.setLayoutParams(params); return v1; }
From source file:com.xabber.android.ui.activity.ContactListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { if (Intent.ACTION_VIEW.equals(getIntent().getAction()) || Intent.ACTION_SEND.equals(getIntent().getAction()) || Intent.ACTION_SENDTO.equals(getIntent().getAction()) || Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) { ActivityManager.getInstance().startNewTask(this); }// w ww .ja v a2 s . com super.onCreate(savedInstanceState); if (isFinishing()) { return; } setContentView(R.layout.activity_contact_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default); toolbar.setOnClickListener(this); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.application_title_short, R.string.application_title_short); drawerLayout.setDrawerListener(drawerToggle); toolbar.inflateMenu(R.menu.toolbar_contact_list); optionsMenu = toolbar.getMenu(); setUpSearchView(optionsMenu); toolbar.setOnMenuItemClickListener(this); toolbar.setOverflowIcon(getResources().getDrawable(R.drawable.ic_overflow_menu_white_24dp)); barPainter = new BarPainter(this, toolbar); barPainter.setDefaultColor(); toolbar.setTitle(R.string.application_title_full); if (savedInstanceState != null) { sendText = savedInstanceState.getString(SAVED_SEND_TEXT); action = savedInstanceState.getString(SAVED_ACTION); } else { getFragmentManager().beginTransaction().add(R.id.container, new ContactListFragment(), CONTACT_LIST_TAG) .commit(); sendText = null; action = getIntent().getAction(); } getIntent().setAction(null); }
From source file:com.piusvelte.sonet.core.StatusDialog.java
private void showDialog() { if (mService == SMS) { // if mRect go straight to message app... if (mRect != null) QuickContact.showQuickContact(this, mRect, Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, mEsid), QuickContact.MODE_LARGE, null); else {/* w ww .j av a2 s.c om*/ startActivity(new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + mEsid))); finish(); } } else if (mService == RSS) { if (mEsid != null) { startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(mEsid))); finish(); } else { (Toast.makeText(StatusDialog.this, "RSS item has no link", Toast.LENGTH_LONG)).show(); finish(); } } else if (items != null) { // offer options for Comment, Post, Settings and Refresh // loading the likes/retweet and other options takes too long, so load them in the SonetCreatePost.class mDialog = (new AlertDialog.Builder(this)).setItems(items, this).setCancelable(true) .setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { finish(); } }).create(); mDialog.show(); } else { if (mAppWidgetId != Sonet.INVALID_ACCOUNT_ID) { // informational messages go to settings mFinish = true; startActivity(Sonet.getPackageIntent(this, ManageAccounts.class) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId)); finish(); } else { (Toast.makeText(StatusDialog.this, R.string.widget_loading, Toast.LENGTH_LONG)).show(); // force widgets rebuild startService(Sonet.getPackageIntent(this, SonetService.class).setAction(ACTION_REFRESH)); finish(); } } }
From source file:org.totschnig.myexpenses.util.Utils.java
public static void share(Context ctx, ArrayList<File> files, String target, String mimeType) { URI uri = null;/* ww w . j a v a 2 s . c om*/ Intent intent; String scheme = "mailto"; boolean multiple = files.size() > 1; if (!target.equals("")) { uri = Utils.validateUri(target); if (uri == null) { Toast.makeText(ctx, ctx.getString(R.string.ftp_uri_malformed, target), Toast.LENGTH_LONG).show(); return; } scheme = uri.getScheme(); } //if we get a String that does not include a scheme, we interpret it as a mail address if (scheme == null) { scheme = "mailto"; } if (scheme.equals("ftp")) { if (multiple) { Toast.makeText(ctx, "sending multiple file through ftp is not supported", Toast.LENGTH_LONG).show(); return; } intent = new Intent(android.content.Intent.ACTION_SENDTO); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(files.get(0))); intent.setDataAndType(android.net.Uri.parse(target), mimeType); if (!isIntentAvailable(ctx, intent)) { Toast.makeText(ctx, R.string.no_app_handling_ftp_available, Toast.LENGTH_LONG).show(); return; } ctx.startActivity(intent); } else if (scheme.equals("mailto")) { if (multiple) { intent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); ArrayList<Uri> uris = new ArrayList<Uri>(); for (File file : files) { uris.add(Uri.fromFile(file)); } intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent = new Intent(android.content.Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(files.get(0))); } intent.setType(mimeType); if (uri != null) { String address = uri.getSchemeSpecificPart(); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address }); } intent.putExtra(Intent.EXTRA_SUBJECT, R.string.export_expenses); if (!isIntentAvailable(ctx, intent)) { Toast.makeText(ctx, R.string.no_app_handling_email_available, Toast.LENGTH_LONG).show(); return; } //if we got mail address, we launch the default application //if we are called without target, we launch the chooser in order to make action more explicit if (uri != null) { ctx.startActivity(intent); } else { ctx.startActivity(Intent.createChooser(intent, ctx.getString(R.string.share_sending))); } } else { Toast.makeText(ctx, ctx.getString(R.string.share_scheme_not_supported, scheme), Toast.LENGTH_LONG) .show(); return; } }