List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:com.achep.base.ui.fragments.dialogs.FeedbackDialog.java
private void send(@NonNull CharSequence title, @NonNull CharSequence body, boolean attachLog) { Activity context = getActivity();/*from www.j a va2 s .c o m*/ String[] recipients = { Build.SUPPORT_EMAIL }; Intent intent = new Intent().putExtra(Intent.EXTRA_EMAIL, recipients).putExtra(Intent.EXTRA_SUBJECT, title) .putExtra(Intent.EXTRA_TEXT, body); if (attachLog) { attachLog(intent); intent.setAction(Intent.ACTION_SEND); intent.setType("message/rfc822"); } else { intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); // only email apps should handle it } if (IntentUtils.hasActivityForThat(context, intent)) { startActivity(intent); dismiss(); } else { ToastUtils.showLong(context, R.string.feedback_error_no_app); } }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java
private void sendToExternalFriend() { Intent share = new Intent(Intent.ACTION_SEND); share.putExtra(Intent.EXTRA_TEXT,/* ww w .jav a2 s. c om*/ "Join me in a Musubi thread: " + ThreadRequest.getInvitationUri(getActivity(), mExternalFeedUri)); share.putExtra(Intent.EXTRA_SUBJECT, "Join me on Musubi!"); share.setType("text/plain"); startActivity(share); }
From source file:mp.paschalis.WatchBookActivity.java
/** * Creates a sharing {@link Intent}.// w w w. j a va2s . co m * * @return The sharing intent. */ private Intent createShareIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); String root = Environment.getExternalStorageDirectory() + ".SmartLib/Images"; new File(root).mkdirs(); File file = new File(root, app.selectedBook.isbn); try { FileOutputStream os = new FileOutputStream(file); bitmapBookCover.compress(CompressFormat.PNG, 80, os); os.flush(); os.close(); Uri uri = Uri.fromFile(file); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); } catch (Exception e) { Log.e(TAG, e.getStackTrace().toString()); } String bookInfo = "\n\n\n\n " + getString(R.string.bookInfo) + ":\n" + getString(R.string.title) + ": \t\t\t\t" + app.selectedBook.title + "\n" + getString(R.string.author) + ": \t\t\t" + app.selectedBook.authors + "\n" + getString(R.string.isbn) + ": \t\t\t\t" + app.selectedBook.isbn + "\n" + getString(R.string.published_) + " \t" + app.selectedBook.publishedYear + "\n" + getString(R.string.pages_) + " \t\t\t" + app.selectedBook.pageCount + "\n" + getString(R.string.isbn) + ": \t\t\t\t" + app.selectedBook.isbn + "\n" + getString(R.string.status) + ": \t\t\t" + App.getBookStatusString(app.selectedBook.status, WatchBookActivity.this) + "\n\n" + "http://books.google.com/books?vid=isbn" + app.selectedBook.isbn; shareIntent.putExtra(Intent.EXTRA_TEXT, bookInfo); return shareIntent; }
From source file:com.rjfun.cordova.sms.SMSPlugin.java
private PluginResult sendSMS(JSONArray addressList, String text, CallbackContext callbackContext) { Log.d(LOGTAG, ACTION_SEND_SMS);/*from w ww . j av a 2 s .c o m*/ if (this.cordova.getActivity().getPackageManager().hasSystemFeature("android.hardware.telephony")) { int n; if ((n = addressList.length()) > 0) { PendingIntent sentIntent = PendingIntent.getBroadcast((Context) this.cordova.getActivity(), (int) 0, (Intent) new Intent("SENDING_SMS"), (int) 0); SmsManager sms = SmsManager.getDefault(); for (int i = 0; i < n; ++i) { String address; if ((address = addressList.optString(i)).length() <= 0) continue; sms.sendTextMessage(address, null, text, sentIntent, (PendingIntent) null); } } else { PendingIntent sentIntent = PendingIntent.getActivity((Context) this.cordova.getActivity(), (int) 0, (Intent) new Intent("android.intent.action.VIEW"), (int) 0); Intent intent = new Intent("android.intent.action.VIEW"); intent.putExtra("sms_body", text); intent.setType("vnd.android-dir/mms-sms"); try { sentIntent.send(this.cordova.getActivity().getApplicationContext(), 0, intent); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, "OK")); } else { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "SMS is not supported")); } return null; }
From source file:com.lepin.activity.CarDriverVerify.java
private void getImageByGallery() { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/jpeg"); startActivityForResult(intent, IMAGE_RESULT); }
From source file:com.android.mail.browse.AttachmentActionHandler.java
public void shareAttachment() { if (mAttachment.contentUri == null) { return;/*w ww. j a v a 2 s . co m*/ } Intent intent = new Intent(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); final Uri uri = Utils.normalizeUri(mAttachment.contentUri); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setType(Utils.normalizeMimeType(mAttachment.getContentType())); try { mContext.startActivity(intent); } catch (ActivityNotFoundException e) { // couldn't find activity for SEND intent LogUtils.e(LOG_TAG, "Couldn't find Activity for intent", e); } }
From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java
/** Handle "share" title-bar action. */ public void onShareClick(View v) { // TODO: consider bringing in shortlink to session final String shareString = getString(R.string.share_template, mTitleString, mHashtag); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, shareString); startActivity(Intent.createChooser(intent, getText(R.string.title_share))); }
From source file:com.kuacm.expo2013.ui.SessionDetailActivity.java
/** Handle "share" title-bar action. */ public void onShareClick(View v) { // TODO: consider bringing in shortlink to session final String shareString = getString(R.string.share_template, mTitleString); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, shareString); startActivity(Intent.createChooser(intent, getText(R.string.title_share))); }
From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java
/** * Setter for the body.//w w w. j a v a2 s .c o m * * @param body * The body of the email. * @param isHTML * Indicates the encoding (HTML or plain text). * @param draft * The intent to send. */ private void setBody(String body, Boolean isHTML, Intent draft) { if (isHTML) { draft.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body)); draft.setType("text/html"); if (Build.VERSION.SDK_INT > 15) { draft.putExtra(Intent.EXTRA_HTML_TEXT, body); } } else { draft.putExtra(Intent.EXTRA_TEXT, body); draft.setType("text/plain"); } }
From source file:com.nbplus.hybrid.BasicWebViewClient.java
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // for excel download if (isDocumentMimeType(url)) { Log.d(TAG, "This url is document mimetype = " + url); if (StorageUtils.isExternalStorageWritable()) { Uri source = Uri.parse(url); // Make a new request pointing to the mp3 url DownloadManager.Request request = new DownloadManager.Request(source); // Use the same file name for the destination File destinationFile = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), source.getLastPathSegment()); request.setDestinationUri(Uri.fromFile(destinationFile)); // Add it to the manager mDownloadManager.enqueue(request); Toast.makeText(mContext, R.string.downloads_requested, Toast.LENGTH_SHORT).show(); } else {/* w ww. j a v a 2s.c om*/ AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setPositiveButton("?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //closeWebApplication(); } }); builder.setMessage(R.string.downloads_path_check); builder.show(); } return true; } if (url.startsWith("tel:")) { // phone call if (!PhoneState.hasPhoneCallAbility(mContext)) { Log.d(TAG, ">> This device has not phone call ability !!!"); return true; } mContext.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url))); } else if (url.startsWith("mailto:")) { url = url.replaceFirst("mailto:", ""); url = url.trim(); Intent i = new Intent(Intent.ACTION_SEND); i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL, new String[] { url }); mContext.startActivity(i); } else if (url.startsWith("geo:")) { Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); mContext.startActivity(searchAddress); } else { // URL ?? ? ??? . dismissProgressDialog(); loadWebUrl(url); showProgressDialog(); } return true; }