List of usage examples for android.content Intent EXTRA_EMAIL
String EXTRA_EMAIL
To view the source code for android.content Intent EXTRA_EMAIL.
Click Source Link
From source file:pl.allegro.foggerexample.ui.ComponentsActivity.java
@OnClick(R.id.mail) protected void onMailClick() { try {//w ww. jav a 2s. c o m Intent mailIntent = new Intent(Intent.ACTION_SEND).setType(getString(R.string.email_message_type)) .putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.e_mail) }) .putExtra(Intent.EXTRA_SUBJECT, getString(R.string.email_topic_prefix)); startActivity(Intent.createChooser(mailIntent, getString(R.string.mail_me_title))); } catch (ActivityNotFoundException e) { Toast.makeText(this, getString(R.string.email_open_fail), Toast.LENGTH_LONG).show(); Ln.e(e); } }
From source file:co.taqat.call.AboutFragment.java
private void sendLogs(Context context, String info) { final String appName = context.getString(R.string.app_name); Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_EMAIL, new String[] { context.getString(R.string.about_bugreport_email) }); i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs"); i.putExtra(Intent.EXTRA_TEXT, info); i.setType("application/zip"); try {//from w w w. j a v a 2 s .co m startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Log.e(ex); } }
From source file:com.cerema.cloud2.ui.activity.LogHistoryActivity.java
/** * Start activity for sending email with logs attached *///from w w w . j a v a2 s . com private void sendMail() { // For the moment we need to consider the possibility that setup.xml // does not include the "mail_logger" entry. This block prevents that // compilation fails in this case. String emailAddress; try { Class<?> stringClass = R.string.class; Field mailLoggerField = stringClass.getField("mail_logger"); int emailAddressId = (Integer) mailLoggerField.get(null); emailAddress = getString(emailAddressId); } catch (Exception e) { emailAddress = ""; } ArrayList<Uri> uris = new ArrayList<Uri>(); // Convert from paths to Android friendly Parcelable Uri's for (String file : Log_OC.getLogFileNames()) { File logFile = new File(mLogPath, file); if (logFile.exists()) { uris.add(Uri.fromFile(logFile)); } } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.putExtra(Intent.EXTRA_EMAIL, emailAddress); String subject = String.format(getString(R.string.log_send_mail_subject), getString(R.string.app_name)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType(MAIL_ATTACHMENT_TYPE); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); try { startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, getString(R.string.log_send_no_mail_app), Toast.LENGTH_LONG).show(); Log_OC.i(TAG, "Could not find app for sending log history."); } }
From source file:com.spit.spirit17.Fragments.DevelopersFragment.java
@Nullable @Override/* w ww .ja v a2 s .co m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_developers, container, false); email1 = (TextView) view.findViewById(R.id.emailId_tejas); email2 = (TextView) view.findViewById(R.id.emailId_shubham); email3 = (TextView) view.findViewById(R.id.emailId_adnan); g1 = (Button) view.findViewById(R.id.google_tejas); g2 = (Button) view.findViewById(R.id.google_shubham); g3 = (Button) view.findViewById(R.id.google_adnan); l1 = (Button) view.findViewById(R.id.linkedin_tejas); l2 = (Button) view.findViewById(R.id.linkedin_shubham); l3 = (Button) view.findViewById(R.id.linkedin_adnan); image1 = (ImageView) view.findViewById(R.id.pic_tejas); image2 = (ImageView) view.findViewById(R.id.pic_shubham); image3 = (ImageView) view.findViewById(R.id.pic_adnan); /*Add Your Pics Here And Not In Xml*/ Picasso.with(getActivity()).load(R.drawable.dev_tejas_bhitle).into(image1); Picasso.with(getActivity()).load(R.drawable.dev_shubham_mahajan).into(image2); Picasso.with(getActivity()).load(R.drawable.dev_adnan_ansari).into(image3); View.OnClickListener linkListener = new View.OnClickListener() { @Override public void onClick(View v) { Uri uri; switch (v.getId()) { /*Google+ links*/ case R.id.google_tejas: uri = Uri.parse(getResources().getString(R.string.googleplus_tejas)); break; case R.id.google_shubham: uri = Uri.parse(getResources().getString(R.string.googleplus_shubham)); break; case R.id.google_adnan: uri = Uri.parse(getResources().getString(R.string.googleplus_adnan)); break; /*LInkedin Links*/ case R.id.linkedin_tejas: uri = Uri.parse(getResources().getString(R.string.linkedin_tejas)); break; case R.id.linkedin_shubham: uri = Uri.parse(getResources().getString(R.string.linkedin_shubham)); break; case R.id.linkedin_adnan: uri = Uri.parse(getResources().getString(R.string.linkedin_adnan)); break; default: uri = Uri.parse(getResources().getString(R.string.linkedin_tejas)); } Intent i = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(i); } catch (Exception e) { Toast.makeText(getActivity(), "Error Loading Link", Toast.LENGTH_SHORT).show(); } } }; View.OnClickListener emailListener = new View.OnClickListener() { @Override public void onClick(View v) { String to = ""; switch (v.getId()) { /*Email Ids*/ case R.id.emailId_tejas: to = getResources().getString(R.string.email_tejas); break; case R.id.emailId_shubham: to = getResources().getString(R.string.email_shubham); break; case R.id.emailId_adnan: to = getResources().getString(R.string.email_adnan); break; } Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setType("text/plain"); intent.setData(Uri.parse("mailto:" + to)); intent.putExtra(Intent.EXTRA_EMAIL, to); try { startActivity(Intent.createChooser(intent, "Send Email")); } catch (Exception e) { Toast.makeText(getActivity(), e.getStackTrace().toString(), Toast.LENGTH_SHORT).show(); } } }; email1.setOnClickListener(emailListener); email2.setOnClickListener(emailListener); email3.setOnClickListener(emailListener); g1.setOnClickListener(linkListener); g2.setOnClickListener(linkListener); g3.setOnClickListener(linkListener); l1.setOnClickListener(linkListener); l2.setOnClickListener(linkListener); l3.setOnClickListener(linkListener); return view; }
From source file:com.raja.knowme.FragmentContact.java
@Override public boolean onContextItemSelected(MenuItem item) { //if(isCallMenu) { //try {/*from ww w .j av a2 s. c o m*/ // startActivity(new Intent(Intent.ACTION_CALL).setData(Uri.parse("tel:"+item.getTitle().toString().trim()))); // } catch (ActivityNotFoundException e) { // Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_SHORT).show(); // } //} else { //if (mConnectivityManager.getActiveNetworkInfo() == null) // Toast.makeText(getActivity(), R.string.error_interenet_connection, Toast.LENGTH_SHORT).show(); //else { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { item.getTitle().toString().trim() }); startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.send_mail))); } //} return true; }
From source file:com.synox.android.ui.activity.LogHistoryActivity.java
/** * Start activity for sending email with logs attached *//* w ww. j a va 2 s . co m*/ private void sendMail() { // For the moment we need to consider the possibility that setup.xml // does not include the "mail_logger" entry. This block prevents that // compilation fails in this case. String emailAddress; try { Class<?> stringClass = R.string.class; Field mailLoggerField = stringClass.getField("mail_logger"); int emailAddressId = (Integer) mailLoggerField.get(null); emailAddress = getString(emailAddressId); } catch (Exception e) { emailAddress = ""; } ArrayList<Uri> uris = new ArrayList<>(); // Convert from paths to Android friendly Parcelable Uri's for (String file : Log_OC.getLogFileNames()) { File logFile = new File(mLogPath, file); if (logFile.exists()) { uris.add(Uri.fromFile(logFile)); } } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.putExtra(Intent.EXTRA_EMAIL, emailAddress); String subject = String.format(getString(R.string.log_send_mail_subject), getString(R.string.app_name)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType(MAIL_ATTACHMENT_TYPE); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); try { startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, getString(R.string.log_send_no_mail_app), Toast.LENGTH_LONG).show(); Log_OC.i(TAG, "Could not find app for sending log history."); } }
From source file:com.g11x.checklistapp.ChecklistItemActivity.java
private void createUI() { TextView name = (TextView) findViewById(R.id.name); name.setText(checklistItem.getName(language)); TextView description = (TextView) findViewById(R.id.description); description.setText(checklistItem.getDescription(language)); Button getDirections = (Button) findViewById(R.id.directions); getDirections.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . ja v a 2 s. c o m*/ public void onClick(View view) { ChecklistItemActivity.this.onClickGetDirections(); } }); Button doneness = (Button) findViewById(R.id.doneness); if (checklistItem.isDone()) { doneness.setTextColor(ContextCompat.getColor(ChecklistItemActivity.this, R.color.primary)); doneness.setPaintFlags(doneness.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); doneness.setText(getResources().getString(R.string.complete)); doneness.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check_box_accent_24dp, 0, 0, 0); } else { doneness.setTextColor(Color.BLACK); doneness.setPaintFlags(doneness.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); doneness.setText(getResources().getString(R.string.mark_as_done)); doneness.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check_box_outline_blank_black_24dp, 0, 0, 0); } doneness.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ChecklistItemActivity.this.onClickIsDone(); } }); Button sendEmail = (Button) findViewById(R.id.send_email); if (checklistItem.getEmail() != null && !checklistItem.getEmail().equals("")) { sendEmail.setVisibility(View.VISIBLE); sendEmail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_EMAIL, checklistItem.getEmail()); intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.sent_from_rst_checklist_app)); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(Intent.createChooser(intent, "Send e-mail")); } } }); } else { sendEmail.setVisibility(View.GONE); } Button call = (Button) findViewById(R.id.call); if (checklistItem.getPhone() != null && !checklistItem.getPhone().equals("")) { call.setVisibility(View.VISIBLE); call.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + checklistItem.getPhone())); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } } }); } else { call.setVisibility(View.GONE); } }
From source file:de.appplant.cordova.plugin.emailcomposer.EmailComposer.java
/** * Setzt die Empfnger der Mail.//from ww w .j a v a 2 s . c om */ private void setRecipients(JSONArray recipients, Intent draft) throws JSONException { String[] receivers = new String[recipients.length()]; for (int i = 0; i < recipients.length(); i++) { receivers[i] = recipients.getString(i); } draft.putExtra(android.content.Intent.EXTRA_EMAIL, receivers); }
From source file:com.ckchan.assignment1.ckchan_todolist.MainActivity.java
@Override //Selecting action bar items public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { Settings();//www . j a v a 2s . c o m return true; } //Handle presses on the action bar items switch (item.getItemId()) { case R.id.summary_info: SummaryInfo(); return true; case R.id.email_all: try { Context context = getApplicationContext(); TaskDatabase taskDatabase = new TaskDatabase(); ; Email email = taskDatabase.loadEmailAddress(context); ArrayList<TodoTask> taskArray = (ArrayList<TodoTask>) taskDatabase.loadTaskData(context); ArrayList<TodoTask> archiveArray = (ArrayList<TodoTask>) taskDatabase.loadArchiveData(context); //StringBuilder code from: //http://stackoverflow.com/questions/12899953/in-java-how-to-append-a-string-more-efficiently StringBuilder stringBuilder = new StringBuilder(); if (email != null) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { email.getAddress() }); i.putExtra(Intent.EXTRA_SUBJECT, "Todo and Archive Tasks"); stringBuilder.append("Todo Tasks\n"); for (TodoTask task : taskArray) { stringBuilder.append(task.getTaskDescription() + "\n"); } stringBuilder.append("Archive Tasks\n"); for (TodoTask task : archiveArray) { stringBuilder.append(task.getTaskDescription() + "\n"); } String emailContent = stringBuilder.toString(); i.putExtra(Intent.EXTRA_TEXT, emailContent); try { startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } default: return super.onOptionsItemSelected(item); } }
From source file:com.fsa.en.dron.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RateThisApp.Config config = new RateThisApp.Config(5, 10); config.setTitle(R.string.my_own_title); config.setMessage(R.string.my_own_message); config.setYesButtonText(R.string.my_own_rate); config.setNoButtonText(R.string.my_own_thanks); config.setCancelButtonText(R.string.my_own_cancel); RateThisApp.init(config);/*from www . ja va 2s .c o m*/ RateThisApp.setCallback(new RateThisApp.Callback() { @Override public void onYesClicked() { final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); } } @Override public void onNoClicked() { TastyToast.makeText(getApplicationContext(), "Vuelve pronto!", TastyToast.LENGTH_LONG, TastyToast.INFO); } @Override public void onCancelClicked() { TastyToast.makeText(getApplicationContext(), "Prometo tomar mejores fotografias!", TastyToast.LENGTH_LONG, TastyToast.ERROR); } }); button = (Button) findViewById(R.id.button); button.setVisibility(View.INVISIBLE); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkConnection(); } }); BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar); bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE); bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED); bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC); bottomNavigationBar.setBarBackgroundColor(R.color.material_light_blue_800); bottomNavigationBar.setActiveColor(R.color.material_grey_900); bottomNavigationBar.setInActiveColor(R.color.material_blue_grey_200); bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.compose, "Mensaje")) .addItem(new BottomNavigationItem(R.drawable.sociales, "Sociales")) .addItem(new BottomNavigationItem(R.drawable.share, "Cuntale a un amigo")).initialise(); bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() { @Override public void onTabSelected(int position) { switch (position) { case 0: Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "marceloespinoza00@gmail.com" }); email.putExtra(Intent.EXTRA_SUBJECT, "Formosa en dron"); email.putExtra(Intent.EXTRA_TEXT, "Dej tu mensaje"); email.setType("message/rfc822"); startActivity(Intent.createChooser(email, "Elige un cliente :")); break; case 1: Intent intent = new Intent(getApplication(), FacebookActivity.class); startActivity(intent); break; case 2: Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Formosa en dron"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.fsa.en.dron"); startActivity(Intent.createChooser(sharingIntent, "Compartir via")); break; } } @Override public void onTabUnselected(int position) { } @Override public void onTabReselected(int position) { switch (position) { case 0: break; case 1: Intent intent = new Intent(getApplication(), FacebookActivity.class); startActivity(intent); break; case 2: break; } } }); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); LayoutInflater inflator = LayoutInflater.from(this); View v = inflator.inflate(R.layout.toolbar_title, null); Typeface budget = Typeface.createFromAsset(getAssets(), "fonts/Budget.otf"); Typeface typographica = Typeface.createFromAsset(getAssets(), "fonts/TypoGraphica.otf"); TextView mToolbarCustomTitle = (TextView) v.findViewById(R.id.title); TextView mToolbarCustomSubTitle = (TextView) v.findViewById(R.id.subtitle); mToolbarCustomTitle.setText("Formosa"); mToolbarCustomSubTitle.setText("en dron"); mToolbarCustomTitle.setTypeface(typographica); mToolbarCustomSubTitle.setTypeface(budget); getSupportActionBar().setCustomView(v); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(true); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { int id = item.getItemId(); if (id == R.id.recargar) { checkConnection(); } if (id == R.id.info) { showDialog(); } return false; } }); recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(), recyclerView, new GalleryAdapter.ClickListener() { @Override public void onClick(View view, int position) { Bundle bundle = new Bundle(); bundle.putSerializable("images", images); bundle.putInt("position", position); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance(); newFragment.setArguments(bundle); newFragment.show(ft, "slideshow"); } @Override public void onLongClick(View view, int position) { } })); pDialog = new ProgressDialog(this); images = new ArrayList<>(); mAdapter = new GalleryAdapter(getApplicationContext(), images); RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(mAdapter); }