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:nuclei.ui.share.PackageTargetManager.java
/** * Create an intent without knowing which package has been chosen *///w w w . j av a 2 s. c o m public Intent onCreateIntent(Context context, String authority) { Intent intent = new Intent( TextUtils.isEmpty(mEmail) && TextUtils.isEmpty(mSms) ? Intent.ACTION_SEND : Intent.ACTION_SENDTO); onSetDefault(context, null, authority, intent, mText); return intent; }
From source file:ru.dublgis.androidhelpers.DesktopUtils.java
public static boolean sendEmail(final Context ctx, final String to, final String subject, final String body, final String attach_file, final boolean force_content_provider, final String authorities) { //Log.d(TAG, "Will send email with subject \"" + // subject + "\" to \"" + to + "\" with attach_file = \"" + attach_file + "\"" + // ", force_content_provider = " + force_content_provider + // ", authorities = \"" + authorities + "\""); try {//from w ww . j av a 2s . c o m // TODO: support multiple recipients String[] recipients = new String[] { to }; final Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", to, null)); List<ResolveInfo> resolveInfos = ctx.getPackageManager().queryIntentActivities(intent, 0); Intent chooserIntent = null; List<Intent> intentList = new ArrayList<Intent>(); Intent i = new Intent(Intent.ACTION_SEND); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, recipients); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, body); Uri workaround_grant_permission_for_uri = null; if (attach_file != null && !attach_file.isEmpty()) { if (!force_content_provider && android.os.Build.VERSION.SDK_INT < 23) { i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(attach_file))); } else { // Android 6+: going the longer route. // For more information, please see: // http://stackoverflow.com/questions/32981194/android-6-cannot-share-files-anymore i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); workaround_grant_permission_for_uri = FileProvider.getUriForFile(ctx, authorities, new File(attach_file)); i.putExtra(Intent.EXTRA_STREAM, workaround_grant_permission_for_uri); } } for (ResolveInfo resolveInfo : resolveInfos) { String packageName = resolveInfo.activityInfo.packageName; String name = resolveInfo.activityInfo.name; // Some mail clients will not read the URI unless this is done. // See here: https://stackoverflow.com/questions/24467696/android-file-provider-permission-denial if (workaround_grant_permission_for_uri != null) { try { ctx.grantUriPermission(packageName, workaround_grant_permission_for_uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); } catch (final Throwable e) { Log.e(TAG, "grantUriPermission error: ", e); } } Intent fakeIntent = (Intent) i.clone(); fakeIntent.setComponent(new ComponentName(packageName, name)); if (chooserIntent == null) { chooserIntent = fakeIntent; } else { intentList.add(fakeIntent); } } if (chooserIntent == null) { chooserIntent = Intent.createChooser(i, null // "Select email application." ); chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else if (!intentList.isEmpty()) { Intent fakeIntent = chooserIntent; chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, fakeIntent); Intent[] extraIntents = intentList.toArray(new Intent[intentList.size()]); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); } ctx.startActivity(chooserIntent); return true; } catch (final Throwable e) { Log.e(TAG, "sendEmail exception: ", e); return false; } }
From source file:gxu.software_engineering.market.android.activity.ItemActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish();//from www .j av a 2 s . c o m break; case R.id.edit: Intent intent = new Intent(this, UpdateItemActivity.class); intent.putExtra(C.ID, getIntent().getLongExtra(C.ID, -1)); startActivity(intent); break; case R.id.call_seller: Cursor c = getContentResolver().query(Uri.parse(C.BASE_URI + C.USERS + "/" + this.uid), new String[] { C.user.CONTACT }, null, null, null); if (!c.moveToNext()) { Toast.makeText(this, R.string.contact_not_found, Toast.LENGTH_SHORT).show(); } else { Intent call = new Intent(Intent.ACTION_CALL); Uri data = Uri.parse("tel:" + c.getString(0)); call.setData(data); startActivity(call); } break; case R.id.sms_seller: Cursor _c = getContentResolver().query(Uri.parse(C.BASE_URI + C.USERS + "/" + this.uid), new String[] { C.user.CONTACT }, null, null, null); if (!_c.moveToNext()) { Toast.makeText(this, R.string.contact_not_found, Toast.LENGTH_SHORT).show(); } else { Intent sms = new Intent(Intent.ACTION_SENDTO); Uri data = Uri.parse("smsto:" + _c.getString(0)); sms.setData(data); startActivity(sms); } break; default: break; } return super.onOptionsItemSelected(item); }
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and composes the described text message (SMS) using the selected application * * @param recipientPhone the recipient's phone number or `null` * @param bodyText the body text of the message * @param captionRes a string resource ID for the title of the application chooser's window * @param context a context reference//from www . ja v a 2 s . c o m * @throws Exception if there was an error trying to launch the SMS application */ public static void sendSms(final String recipientPhone, final String bodyText, final int captionRes, final Context context) throws Exception { final Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType(HTTP.PLAIN_TEXT_TYPE); if (recipientPhone != null && recipientPhone.length() > 0) { intent.setData(Uri.parse("smsto:" + recipientPhone)); } else { intent.setData(Uri.parse("sms:")); } intent.putExtra("sms_body", bodyText); intent.putExtra(Intent.EXTRA_TEXT, bodyText); if (context != null) { // offer a selection of all applications that can handle the SMS Intent context.startActivity(Intent.createChooser(intent, context.getString(captionRes))); } }
From source file:org.schabi.newpipe.ErrorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_error); getSupportActionBar().setDisplayHomeAsUpEnabled(true); ActivityCommunicator ac = ActivityCommunicator.getCommunicator(); errorList = ac.errorList;/*from w w w .j a v a2s . com*/ returnActivity = ac.returnActivity; errorInfo = ac.errorInfo; reportButton = (Button) findViewById(R.id.errorReportButton); userCommentBox = (EditText) findViewById(R.id.errorCommentBox); errorView = (TextView) findViewById(R.id.errorView); infoView = (TextView) findViewById(R.id.errorInfosView); errorMessageView = (TextView) findViewById(R.id.errorMessageView); errorView.setText(formErrorText(errorList)); //importand add gurumeditaion addGuruMeditaion(); currentTimeStamp = getCurrentTimeStamp(); buildInfo(errorInfo); reportButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:" + ERROR_EMAIL_ADDRESS)) .putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT) .putExtra(Intent.EXTRA_TEXT, buildJson()); startActivity(Intent.createChooser(intent, "Send Email")); } }); reportButton.setEnabled(false); globIpRangeThread = new Thread(new IpRagneRequester()); globIpRangeThread.start(); if (errorInfo.message != 0) { errorMessageView.setText(errorInfo.message); } else { errorMessageView.setVisibility(View.GONE); findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE); } }
From source file:ir.rasen.charsoo.view.fragment.invite.FragmentInviteSMS.java
private void doSendSMS() { if (selectedContactsToInvite.size() > 0) { // if (selectedContactsToInvite.size() <= remainingSMSCount) { // // TODO: SEND SMS REQUEST TO SERVER // } else { String numbers;/*from w ww.j a va2 s .c o m*/ ArrayList<Integer> keys = new ArrayList<>(selectedContactsToInvite.keySet()); numbers = selectedContactsToInvite.get(keys.get(0)).contactData; for (int i = 1; i < keys.size(); i++) { numbers += ";"; numbers += selectedContactsToInvite.get(keys.get(i)).contactData; } Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + numbers)); if (!FragmentInvite.isBusinessPromotion) { String Userid = "@" + ((MyApplication) parentactivity.getApplication()).userIdentifier; smsIntent.putExtra("sms_body", getActivity().getString(R.string.txt_sms_body) + '\n' + Userid + '\n' + "http://www.icharsoo.com"); } else { // second type for sms String business_name = FragmentInvite.Business_name; String business_id = FragmentInvite.Business_id; smsIntent.putExtra("sms_body", " " + business_name + " ? ." + '\n' + "@" + business_id + '\n' + "http://www.icharsoo.com"); } startActivity(smsIntent); // } } }
From source file:com.atahani.telepathy.ui.fragment.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View customLayout = inflater.inflate(R.layout.fragment_about_dialog, null); //config app version information mAppPreferenceTools = new AppPreferenceTools(TApplication.applicationContext); AppCompatTextView txAndroidAppVerInfo = (AppCompatTextView) customLayout .findViewById(R.id.tx_android_ver_info); txAndroidAppVerInfo.setText(String.format(getString(R.string.label_telepathy_for_android), mAppPreferenceTools.getTheLastAppVersion())); txAndroidAppVerInfo.setOnClickListener(new View.OnClickListener() { @Override//from www . j ava 2 s . co m public void onClick(View v) { try { //open browser to navigate telepathy website Uri telepathyWebSiteUri = Uri.parse("https://github.com/atahani/telepathy-android.git"); startActivity(new Intent(Intent.ACTION_VIEW, telepathyWebSiteUri)); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); //config google play store link AppCompatTextView txRateUsOnGooglePlayStore = (AppCompatTextView) customLayout .findViewById(R.id.tx_rate_us_on_play_store); txRateUsOnGooglePlayStore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //navigate to market for rate application Uri uri = Uri.parse("market://details?id=" + TApplication.applicationContext.getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); // To count with Play market backstack, After pressing back button, // to taken back to our application, we need to add following flags to intent. goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); try { startActivity(goToMarket); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (ActivityNotFoundException e) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + TApplication.applicationContext.getPackageName()))); } } }); //config twitter link AppCompatTextView txTwitterLink = (AppCompatTextView) customLayout.findViewById(R.id.tx_twitter_telepathy); txTwitterLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { // If Twitter app is not installed, start browser. Uri twitterUri = Uri.parse("http://twitter.com/"); startActivity(new Intent(Intent.ACTION_VIEW, twitterUri)); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); //config privacy link AppCompatTextView txPrivacyLink = (AppCompatTextView) customLayout.findViewById(R.id.tx_privacy); txPrivacyLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { //open browser to navigate privacy link Uri privacyPolicyUri = Uri .parse("https://github.com/atahani/telepathy-android/blob/master/LICENSE.md"); startActivity(new Intent(Intent.ACTION_VIEW, privacyPolicyUri)); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); //config report bug to open mail application and send bugs report AppCompatTextView txReportBug = (AppCompatTextView) customLayout.findViewById(R.id.tx_report_bug); txReportBug.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { final Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.label_report_bug_email_subject)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailDeviceInformation()); emailIntent.setData(Uri.parse("mailto:" + getString(R.string.telepathy_report_bug_email))); startActivity(Intent.createChooser(emailIntent, getString(R.string.label_report_bug_choose_mail_app))); ((TelepathyBaseActivity) getActivity()).setAnimationOnStart(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); //config the about footer image view AboutFooterImageView footerImageView = (AboutFooterImageView) customLayout .findViewById(R.id.im_delete_user_account); footerImageView.setTouchOnImageViewEventListener(new AboutFooterImageView.touchOnImageViewEventListener() { @Override public void onDoubleTab() { try { //confirm account delete via alert dialog final AlertDialog.Builder confirmAccountDeleteDialog = new AlertDialog.Builder(getActivity()); confirmAccountDeleteDialog.setTitle(getString(R.string.label_delete_user_account)); confirmAccountDeleteDialog .setMessage(getString(R.string.label_delete_user_account_description)); confirmAccountDeleteDialog.setNegativeButton(getString(R.string.action_no), null); confirmAccountDeleteDialog.setPositiveButton(getString(R.string.action_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //ok to delete account action final ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setCancelable(false); progressDialog.setCanceledOnTouchOutside(false); progressDialog .setMessage(getString(R.string.re_action_on_deleting_user_account)); progressDialog.show(); TService tService = ((TelepathyBaseActivity) getActivity()).getTService(); tService.deleteUserAccount(new Callback<TOperationResultModel>() { @Override public void success(TOperationResultModel tOperationResultModel, Response response) { if (getActivity() != null && isAdded()) { //broad cast to close all of the realm instance Intent intentToCloseRealm = new Intent( Constants.TELEPATHY_BASE_ACTIVITY_INTENT_FILTER); intentToCloseRealm.putExtra(Constants.ACTION_TO_DO_PARAM, Constants.CLOSE_REALM_DB); LocalBroadcastManager.getInstance(getActivity()) .sendBroadcastSync(intentToCloseRealm); mAppPreferenceTools.removeAllOfThePref(); // for sign out google first build GoogleAPIClient final GoogleApiClient googleApiClient = new GoogleApiClient.Builder( TApplication.applicationContext) .addApi(Auth.GOOGLE_SIGN_IN_API).build(); googleApiClient.connect(); googleApiClient.registerConnectionCallbacks( new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(Bundle bundle) { Auth.GoogleSignInApi.signOut(googleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult( Status status) { //also revoke google access Auth.GoogleSignInApi .revokeAccess( googleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult( Status status) { progressDialog .dismiss(); TelepathyBaseActivity currentActivity = (TelepathyBaseActivity) TApplication.mCurrentActivityInApplication; if (currentActivity != null) { Intent intent = new Intent( TApplication.applicationContext, SignInActivity.class); intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); currentActivity .startActivity( intent); currentActivity .setAnimationOnStart(); currentActivity .finish(); } } }); } }); } @Override public void onConnectionSuspended(int i) { //do nothing } }); } } @Override public void failure(RetrofitError error) { progressDialog.dismiss(); if (getActivity() != null && isAdded()) { CommonFeedBack commonFeedBack = new CommonFeedBack( getActivity().findViewById(android.R.id.content), getActivity()); commonFeedBack.checkCommonErrorAndBackUnCommonOne(error); } } }); } }); confirmAccountDeleteDialog.show(); } catch (Exception ex) { AndroidUtilities.processApplicationError(ex, true); if (isAdded() && getActivity() != null) { Snackbar.make(getActivity().findViewById(android.R.id.content), getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show(); } } } }); builder.setView(customLayout); return builder.create(); }
From source file:de.tu_berlin.snet.commstat.SensorFragment.java
private void sendMail() { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "ssakar@mailbox.tu-berlin.de", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "[Commstat] "); startActivity(Intent.createChooser(emailIntent, "Send email...")); }
From source file:io.nuclei.cyto.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 w w . ja va 2s.c o 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) ? 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, intent, permissionRequestCode); break; case INSTAGRAM: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) intent = onExternalStorage(activity, intent, permissionRequestCode); break; } return intent; }
From source file:spit.matrix2017.Fragments.DevelopersFragment.java
@Nullable @Override// www . ja va 2 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_adnan); email3 = (TextView) view.findViewById(R.id.emailId_rohit); email4 = (TextView) view.findViewById(R.id.emailId_mithil); email5 = (TextView) view.findViewById(R.id.emailId_akshay); email6 = (TextView) view.findViewById(R.id.emailId_shubham); g1 = (Button) view.findViewById(R.id.google_tejas); g2 = (Button) view.findViewById(R.id.google_adnan); g3 = (Button) view.findViewById(R.id.google_rohit); g4 = (Button) view.findViewById(R.id.google_mithil); g5 = (Button) view.findViewById(R.id.google_akshay); g6 = (Button) view.findViewById(R.id.google_shubham); l1 = (Button) view.findViewById(R.id.linkedin_tejas); l2 = (Button) view.findViewById(R.id.linkedin_adnan); l3 = (Button) view.findViewById(R.id.linkedin_rohit); l4 = (Button) view.findViewById(R.id.linkedin_mithil); l5 = (Button) view.findViewById(R.id.linkedin_akshay); l6 = (Button) view.findViewById(R.id.linkedin_shubham); image1 = (ImageView) view.findViewById(R.id.pic_tejas); image2 = (ImageView) view.findViewById(R.id.pic_adnan); image3 = (ImageView) view.findViewById(R.id.pic_rohit); image4 = (ImageView) view.findViewById(R.id.pic_mithil); image5 = (ImageView) view.findViewById(R.id.pic_akshay); image6 = (ImageView) view.findViewById(R.id.pic_shubham); /*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_adnan_ansari).into(image2); Picasso.with(getActivity()).load(R.drawable.dev_rohit_nahata).into(image3); Picasso.with(getActivity()).load(R.drawable.dev_mithil_gotarne).into(image4); Picasso.with(getActivity()).load(R.drawable.dev_akshay_shah).into(image5); Picasso.with(getActivity()).load(R.drawable.dev_shubham_mahajan).into(image6); 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_adnan: uri = Uri.parse(getResources().getString(R.string.googleplus_adnan)); break; case R.id.google_rohit: uri = Uri.parse(getResources().getString(R.string.googleplus_rohit)); break; case R.id.google_mithil: uri = Uri.parse(getResources().getString(R.string.googleplus_mithil)); break; case R.id.google_akshay: uri = Uri.parse(getResources().getString(R.string.googleplus_akshay)); break; case R.id.google_shubham: uri = Uri.parse(getResources().getString(R.string.googleplus_shubham)); break; /*LInkedin Links*/ case R.id.linkedin_tejas: uri = Uri.parse(getResources().getString(R.string.linkedin_tejas)); break; case R.id.linkedin_adnan: uri = Uri.parse(getResources().getString(R.string.linkedin_adnan)); break; case R.id.linkedin_rohit: uri = Uri.parse(getResources().getString(R.string.linkedin_rohit)); break; case R.id.linkedin_mithil: uri = Uri.parse(getResources().getString(R.string.linkedin_mithil)); break; case R.id.linkedin_akshay: uri = Uri.parse(getResources().getString(R.string.linkedin_akshay)); break; case R.id.linkedin_shubham: uri = Uri.parse(getResources().getString(R.string.linkedin_shubham)); 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_adnan: to = getResources().getString(R.string.email_adnan); break; case R.id.emailId_rohit: to = getResources().getString(R.string.email_rohit); break; case R.id.emailId_mithil: to = getResources().getString(R.string.email_mithil); break; case R.id.emailId_akshay: to = getResources().getString(R.string.email_akshay); break; case R.id.emailId_shubham: to = getResources().getString(R.string.email_shubham); 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); email4.setOnClickListener(emailListener); email5.setOnClickListener(emailListener); email6.setOnClickListener(emailListener); g1.setOnClickListener(linkListener); g2.setOnClickListener(linkListener); g3.setOnClickListener(linkListener); g4.setOnClickListener(linkListener); g5.setOnClickListener(linkListener); g6.setOnClickListener(linkListener); l1.setOnClickListener(linkListener); l2.setOnClickListener(linkListener); l3.setOnClickListener(linkListener); l4.setOnClickListener(linkListener); l5.setOnClickListener(linkListener); l6.setOnClickListener(linkListener); return view; }