List of usage examples for android.content Intent EXTRA_TEXT
String EXTRA_TEXT
To view the source code for android.content Intent EXTRA_TEXT.
Click Source Link
From source file:com.example.android.naradaonline.DatagramFragment.java
protected final void sendEmail(DatagramRequest data) { if (data.type != DatagramRequestType.SEND_EMAIL) { Log.w(TAG, "This datagram is actually of type " + data.type.name()); }//from w ww. j a v a 2 s. c om Log.i("Send email", ""); String[] TO = { data.mEmailTo }; Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setData(Uri.parse("mailto:")); emailIntent.setType("text/plain"); emailIntent.putExtra(Intent.EXTRA_EMAIL, TO); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your Datagram"); emailIntent.putExtra(Intent.EXTRA_TEXT, data.mEmailBody); try { startActivity(Intent.createChooser(emailIntent, "Send mail...")); Log.i("Finished sending email...", ""); } catch (android.content.ActivityNotFoundException ex) { // Toast.makeText(MainActivity.this, // "There is no email client installed.", Toast.LENGTH_SHORT).show(); } }
From source file:com.bangz.shotrecorder.RecordActivity.java
private void SetShareIntent() { if (mShareActionProvider == null) return;//from w w w. j a v a2s . c o m if (mSplitManager.getNumbers() > 0) { String strDescription = ""; String strNumber = textNumber.getText().toString(); String strTime = String.format("%.02f", mSplitManager.getTotalElapsedTime() / 1000.0f); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); String strDate = df.format(date); String strcontent = String.format(getResources().getString(R.string.share_content), strDescription, strNumber, strTime, strDate); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, strcontent); mShareActionProvider.setShareIntent(intent); } else { mShareActionProvider.setShareIntent(null); } }
From source file:ca.mymenuapp.ui.activities.RestaurantActivity.java
private void setShareIntent(RestaurantMenu menu) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); // todo check if this item has a picture shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_restaurant, menu.getRestaurant().businessName, menu.getRestaurant().businessPicture)); shareIntent.setType("text/plain"); shareActionProvider.setShareIntent(shareIntent); }
From source file:com.becapps.easydownloader.ShareActivity.java
void handleSendText(Intent intent, String action) throws IOException { ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { String sharedText = null; if (action.equals(Intent.ACTION_SEND)) { sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); } else if (action.equals(Intent.ACTION_VIEW)) { sharedText = intent.getDataString(); }//from w ww . j a v a 2s. co m if (sharedText != null) { if (linkValidator(sharedText) == "not_a_valid_video_link") { badOrNullLinkAlert(); } else if (sharedText != null) { showGeneralInfoTutorial(); asyncDownload = new AsyncDownload(); asyncDownload.execute(validatedLink); } } else { badOrNullLinkAlert(); } } else { progressBar1.setVisibility(View.GONE); tv.setText(getString(R.string.no_net)); PopUps.showPopUp(getString(R.string.no_net), getString(R.string.no_net_dialog_msg), "alert", this); Button retry = (Button) findViewById(R.id.share_activity_retry_button); retry.setVisibility(View.VISIBLE); retry.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Utils.reload(ShareActivity.this); } }); } }
From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java
/** * ??Email// w ww . j a va 2 s. com * * @param addr * ? * @param body * ? * @param subject * ? * @return ? */ private void sendEmail(String addr, String body, String subject) { String aEmailList[] = { addr }; Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); mContext.startActivity(emailIntent); mCallbackContext.success(); }
From source file:activeng.pt.activenglab.BluetoothChatService.java
/** * Indicate that the connection attempt failed and notify the UI Activity. *///from ww w .j av a 2 s.c o m private void connectionFailed() { /* // Send a failure message back to the Activity Message msg = mHandler.obtainMessage(Constants.MESSAGE_TOAST); Bundle bundle = new Bundle(); bundle.putString(Constants.TOAST, "Unable to connect device"); msg.setData(bundle); mHandler.sendMessage(msg); */ Intent intent = new Intent(Constants.MESSAGE_BT_FAIL).putExtra(Intent.EXTRA_TEXT, "Unable to connect device"); //mContext.sendBroadcast(intent); LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent); // Start the service over to restart listening mode BluetoothChatService.this.start(); }
From source file:com.polyvi.xface.extension.XMessagingExt.java
/** * ??Email/* www . j a v a 2 s .c o m*/ * @param addr ? * @param body ? * @param subject ? * @return ? */ private XExtensionResult sendEmail(String addr, String body, String subject) { String aEmailList[] = { addr }; Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); getContext().startActivity(emailIntent); return new XExtensionResult(XExtensionResult.Status.OK, ""); }
From source file:ca.ualberta.cs.drivr.RequestsListAdapter.java
/** * Called when the view holder is wants to bind the request at a certain position in the list. * @param viewHolder/*from w w w.ja v a 2 s . com*/ * @param position */ @Override public void onBindViewHolder(final RequestsListAdapter.ViewHolder viewHolder, final int position) { final Request request = requestsToDisplay.get(position); // Get the views to update final TextView otherUserNameTextView = viewHolder.otherUserNameTextView; final TextView descriptionTextView = viewHolder.descriptionTextView; final TextView fareTextView = viewHolder.fareTextView; final TextView routeTextView = viewHolder.routeTextView; final TextView statusTextView = viewHolder.statusTextView; final ImageView callImageView = viewHolder.callImageView; final ImageView emailImageView = viewHolder.emailImageView; final ImageView checkImageView = viewHolder.checkMarkImageView; final ImageView deleteImageView = viewHolder.xMarkImageView; // Todo Hide Image Views until correct Request State if (request.getRequestState() != RequestState.CONFIRMED) { checkImageView.setVisibility(View.INVISIBLE); } if (request.getRequestState() != RequestState.PENDING) { deleteImageView.setVisibility(View.INVISIBLE); } // Show the other person's name final DriversList drivers = request.getDrivers(); // Get the username of the other user if (userManager.getUserMode() == UserMode.RIDER) { final String multipleDrivers = "Multiple Drivers Accepted"; final String driverUsername = drivers.size() == 1 ? drivers.get(0).getUsername() : "No Driver Yet"; otherUserNameTextView.setText(drivers.size() > 1 ? multipleDrivers : driverUsername); } else { otherUserNameTextView.setText(request.getRider().getUsername()); } // If the request has a description, show it. Otherwise, hide te description if (Strings.isNullOrEmpty(request.getDescription())) descriptionTextView.setVisibility(View.GONE); else descriptionTextView.setText(request.getDescription()); // Show the fare fareTextView.setText("$" + request.getFareString()); // Show the route routeTextView.setText(request.getRoute()); // Driver User otherUserNameTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String otherUsername = otherUserNameTextView.getText().toString(); // there exists drivers if (otherUsername != "No Driver Yet") { if (otherUsername != "Multiple Drivers Accepted") { Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create(); ElasticSearch elasticSearch = new ElasticSearch( UserManager.getInstance().getConnectivityManager()); User user = elasticSearch.loadUser(otherUsername); String driverString = gson.toJson(user, User.class); Intent intent = new Intent(context, DriverProfileActivity.class); intent.putExtra(DriverProfileActivity.DRIVER, driverString); context.startActivity(intent); } else { startMultipleDriverIntent(request); } } } }); routeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create(); String requestString = gson.toJson(request, Request.class); Intent intent = new Intent(context, RequestActivity.class); intent.putExtra("UniqueID", "From_RequestListActivity"); intent.putExtra(RequestActivity.EXTRA_REQUEST, requestString); context.startActivity(intent); } }); // Show the status text statusTextView.setText(request.getRequestState().toString()); // Add a listener to the call image callImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (drivers.size() == 0) { Toast.makeText(context, "No driver number available at this time", Toast.LENGTH_SHORT).show(); } // Start Dialer else if (drivers.size() == 1) { Intent intent = new Intent(Intent.ACTION_CALL); String number; if (UserManager.getInstance().getUserMode().equals(UserMode.RIDER)) { number = drivers.get(0).getPhoneNumber(); } else { number = request.getRider().getPhoneNumber(); } number = "tel:" + number; intent.setData(Uri.parse(number)); if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } context.startActivity(intent); } else { startMultipleDriverIntent(request); } } }); // Add a listener to the email image emailImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (drivers.size() == 0) { Toast.makeText(context, "No driver email available at this time", Toast.LENGTH_SHORT).show(); } //http://stackoverflow.com/questions/8701634/send-email-intent else if (drivers.size() == 1) { Intent intent = new Intent(); ComponentName emailApp = intent.resolveActivity(context.getPackageManager()); ComponentName unsupportedAction = ComponentName .unflattenFromString("com.android.fallback/.Fallback"); boolean hasEmailApp = emailApp != null && !emailApp.equals(unsupportedAction); String email; if (UserManager.getInstance().getUserMode().equals(UserMode.RIDER)) { email = drivers.get(0).getEmail(); } else { email = request.getRider().getEmail(); } String subject = "Drivr Request: " + request.getId(); String body = "Drivr user " + drivers.get(0).getUsername(); if (hasEmailApp) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); context.startActivity(Intent.createChooser(emailIntent, "Chooser Title")); } else { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, ""); emailIntent.putExtra(Intent.EXTRA_TEXT, ""); context.startActivity(Intent.createChooser(emailIntent, "Send email...")); } } else { startMultipleDriverIntent(request); } } }); // Complete The Request checkImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(context, RequestCompletedActivity.class); intent.putExtra(RequestCompletedActivity.REQUEST_ID_EXTRA, request.getId()); context.startActivity(intent); } }); deleteImageView.setOnClickListener(new View.OnClickListener() { // Todo Delete the Request @Override public void onClick(View v) { v.getContext(); ElasticSearch elasticSearch = new ElasticSearch( (ConnectivityManager) v.getContext().getSystemService(Context.CONNECTIVITY_SERVICE)); elasticSearch.deleteRequest(request.getId()); UserManager userManager = UserManager.getInstance(); userManager.getRequestsList().removeById(request); userManager.notifyObservers(); requestsToDisplay.remove(request); notifyItemRemoved(viewHolder.getAdapterPosition()); } }); }
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final Resources res = getResources(); if (item.getItemId() == R.id.menu_favorites_toggle) { onCheckedChanged(mIsStarred);//from w w w . j a v a2 s . c o m mIsStarred = (mIsStarred ? false : true); // Toggle value getSherlockActivity().invalidateOptionsMenu(); return true; } else if (item.getItemId() == R.id.menu_map) { final Intent intent = new Intent(getActivity(), MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(Const.INTENT_EXTRA_GEO_LAT, mGeoLat); intent.putExtra(Const.INTENT_EXTRA_GEO_LNG, mGeoLng); intent.putExtra(Const.INTENT_EXTRA_POST_ID, mIdPost); startActivity(intent); return true; } else if (item.getItemId() == R.id.menu_reminder) { parkingApp.showToastText(R.string.toast_todo_reminder, Toast.LENGTH_LONG); return true; } else if (item.getItemId() == R.id.menu_directions) { if ((Double.compare(mGeoLat, Double.MIN_VALUE) != 0) && (Double.compare(mGeoLng, Double.MIN_VALUE) != 0)) { /** * Get directions using Intents. */ try { final Uri uriNavigation = Uri .parse(String.format(Const.URI_INTENT_NAVIGATION, mGeoLat, mGeoLng)); final Intent intent = new Intent(Intent.ACTION_VIEW, uriNavigation); startActivity(intent); } catch (Exception e) { e.printStackTrace(); String sAddr = ""; Location userLocation = parkingApp.getLocation(); if (userLocation != null) { sAddr = Double.toString(userLocation.getLatitude()) + "," + Double.toString(userLocation.getLongitude()); } final String urlGmaps = String.format(Const.URL_GMAPS_DIRECTIONS, sAddr, mGeoLat + "," + mGeoLng); final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlGmaps)); startActivity(intent); } } return true; } else if (item.getItemId() == R.id.menu_streetview) { if ((Double.compare(mGeoLat, Double.MIN_VALUE) != 0) && (Double.compare(mGeoLng, Double.MIN_VALUE) != 0)) { try { final Uri uriStreetView = Uri .parse(String.format(Const.URI_INTENT_STREETVIEW, mGeoLat, mGeoLng)); final Intent intent = new Intent(Intent.ACTION_VIEW, uriStreetView); startActivity(intent); } catch (NullPointerException e) { e.printStackTrace(); return false; } catch (Exception e) { parkingApp.showToastText(R.string.toast_streetview_error, Toast.LENGTH_LONG); e.printStackTrace(); final Uri uriInstallStreetView = Uri.parse(Const.URI_INSTALL_STREETVIEW); final Intent intent = new Intent(Intent.ACTION_VIEW, uriInstallStreetView); startActivity(intent); return false; } } return true; } else if (item.getItemId() == R.id.menu_share) { final GregorianCalendar parkingCalendar = parkingApp.getParkingCalendar(); final int dayOfWeek = (parkingCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY ? 7 : parkingCalendar.get(Calendar.DAY_OF_WEEK) - 1); final double parkingHour = parkingCalendar.get(Calendar.HOUR_OF_DAY) + Math.round(parkingCalendar.get(Calendar.MINUTE) / 0.6) / 100.00d; // final int duration = parkingApp.getParkingDuration(); final String url = String.format(res.getString(R.string.url_share_post_id), mIdPost, dayOfWeek, parkingHour, parkingApp.getParkingDuration()); final String subject = String.format(res.getString(R.string.details_share_title), url); final String desc = String.format(res.getString(R.string.details_share_subtitle), mShareDesc); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); // EXTRA_SUBJECT is not used to allow sharing with SMS instead of // MMS // intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, subject + Const.LINE_SEPARATOR + desc); startActivity(intent); return true; } return (activityHelper.onOptionsItemSelected(item) || super.onOptionsItemSelected(item)); }
From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java
public static void shareImage(Fragment fragment, JSONParcelable imageData) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); try {/*from www .j a va 2 s. com*/ intent.putExtra(Intent.EXTRA_TEXT, imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK)); } catch (JSONException e) { Log.e("Error!", "bad link to share"); } fragment.startActivity(intent); }