Example usage for android.content Intent ACTION_SEND

List of usage examples for android.content Intent ACTION_SEND

Introduction

In this page you can find the example usage for android.content Intent ACTION_SEND.

Prototype

String ACTION_SEND

To view the source code for android.content Intent ACTION_SEND.

Click Source Link

Document

Activity Action: Deliver some data to someone else.

Usage

From source file:com.fvd.nimbus.BrowseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
    //overridePendingTransition(R.anim.carbon_slide_in,R.anim.carbon_slide_out);
    //overridePendingTransition(R.anim.activity_open_scale,R.anim.activity_close_translate);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    try {/*from   w w  w. java2  s  .c  o  m*/
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    } catch (Exception e) {
        e.printStackTrace();
    }
    clipData = new DataExchange();
    isInitNow = true;
    setContentView(R.layout.screen_browser);
    serverHelper.getInstance().setCallback(this, this);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    lastUrl = prefs.getString("LAST_URL", "");
    saveCSS = prefs.getString("clipStyle", "1").equals("1");
    ctx = this;

    //adapter = new TextAdapter(this);      

    /*Uri data = getIntent().getData();
    if(data!=null){
       lastUrl=data.toString();
    }*/
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (Intent.ACTION_VIEW.equals(action) /*&& type != null*/) {
        Uri data = intent.getData();
        if (data != null) {
            lastUrl = data.toString();
            appSettings.appendLog("browse:onCreate  " + lastUrl);
        }
    } else if (Intent.ACTION_SEND.equals(action) /*&& type != null*/) {
        if ("text/plain".equals(type)) {
            String surl = intent.getStringExtra(Intent.EXTRA_TEXT);
            if (surl.contains(" ")) {
                String[] arr = surl.replace("\t", " ").split(" ");
                for (String s : arr) {
                    if (s.contains("://")) {
                        lastUrl = s.trim();
                        break;
                    }
                }
            } else if (surl.contains("://"))
                lastUrl = surl.trim();
            appSettings.appendLog("browse:onCreate  " + lastUrl);
        }
    }

    drawer = (DrawerLayout) findViewById(R.id.root);

    View v = findViewById(R.id.wv);
    wv = (fvdWebView) findViewById(R.id.wv);
    wv.setEventsHandler(this);
    //registerForContextMenu(wv); 
    urlField = (AutoCompleteTextView) findViewById(R.id.etAddess);
    urlField.setSelectAllOnFocus(true);
    urlField.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                /*InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);*/
                onNavButtonClicked();
                return true;
            } else if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                onNavButtonClicked();
                return true;
            }
            return false;
        }
    });
    onViewCreated();

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 0:
                findViewById(R.id.bZoomStack).setVisibility(View.VISIBLE);
                findViewById(R.id.bToggleMenu).setVisibility(View.GONE);

                break;

            default:
                break;
            }
        }
    };

    navButton = (ImageButton) findViewById(R.id.ibReloadWebPage);
    navButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //Toast.makeText(getApplicationContext(), "You made a mess", Toast.LENGTH_LONG).show();
            onNavButtonClicked();
        }
    });

    findViewById(R.id.bSavePageFragment).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //toggleTools();
            floatMenu.collapse();
            if (!wv.getInjected())
                Toast.makeText(ctx, getString(R.string.wait_load), Toast.LENGTH_LONG).show();
            clipMode = 2;
            if (wv.getInjected()/* && !v.isSelected()*/) {
                wv.setCanClip(true);
                v.setSelected(true);
                Toast.makeText(ctx, ctx.getString(R.string.use_longtap), Toast.LENGTH_LONG).show();
            }

        }
    });

    (findViewById(R.id.bSaveFullPage)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            floatMenu.collapse();
            if (wv.getInjected()) {
                wv.setCanClip(false);
                wv.saveArticle();
                clipMode = 1;
                progressDialog = ProgressDialog.show(v.getContext(), "Nimbus Clipper",
                        getString(R.string.please_wait), true, false);
            } else {
                Toast.makeText(ctx, getString(R.string.wait_load), Toast.LENGTH_LONG).show();
            }
        }
    });

    findViewById(R.id.bTakeScreenshot).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //toggleTools();
            floatMenu.collapse();
            findViewById(R.id.bSaveFullPage).setVisibility(View.GONE);
            findViewById(R.id.bSavePageFragment).setVisibility(View.GONE);
            findViewById(R.id.bTakeScreenshot).setVisibility(View.GONE);
            if (wv.getInjected()) {
                wv.setCanClip(false);
            }
            findViewById(R.id.bToggleMenu).setVisibility(View.GONE);
            /*screenCapture();
            findViewById(R.id.bToggleMenu).setVisibility(View.VISIBLE);*/

            findViewById(R.id.bTakeScreenshot).postDelayed(new Runnable() {
                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    screenCapture();
                    findViewById(R.id.bToggleMenu).setVisibility(View.VISIBLE);
                    finish();
                }
            }, 10);

            //showDialog(DIALOG_CAPTURE);
        }
    });

    (findViewById(R.id.bDone)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            {
                try {

                    wv.setCanClip(false);
                    wv.endSelectionMode();
                    //findViewById(R.id.bSavePageFragment).setSelected(false);
                    clipMode = 2;
                    wv.endSelectionMode();
                    String selHtml = clipData.getContent();
                    if (selHtml.length() > 0) {
                        String ss = selHtml.substring(0, selHtml.indexOf(">") + 1).toLowerCase();
                        int j = ss.indexOf("<div");
                        if (j == 0) {
                            j = ss.indexOf("style");
                            if (j > 0) {
                                int k = ss.indexOf("\"", j + 11);
                                if (k > 0)
                                    selHtml = selHtml.replace(selHtml.substring(j, k + 1), "");
                            }
                            //selHtml="<DIV>"+selHtml.substring(ss.length());
                        }
                        clipData.setContent(selHtml);
                        clipData.setTitle(wv.getTitle());

                        /*if (true){
                                    
                            if(sessionId.length() == 0 || userPass.length()==0) showSettings();
                            else {
                               if(prefs.getBoolean("check_fast", false)){
                         sendNote(wv.getTitle(), clipData.getContent(), parent, tag);
                         clipData.setContent("");
                               }
                               else {
                               //serverHelper.getInstance().setCallback(this,this);
                               if(appSettings.sessionId.length()>0) {
                         serverHelper.getInstance().sendRequest("notes:getFolders", "","");
                         }
                               }
                            }
                            wv.endSelectionMode();
                         } */

                        Intent i = new Intent(getApplicationContext(), previewActivity.class);
                        i.putExtra("content", clipData);
                        startActivityForResult(i, 5);
                        //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
                        overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
                    }
                    //clipData.setContent("");
                } catch (Exception e) {
                    BugReporter.Send("onEndSelection", e.getMessage());
                }
            }
            //showDialog(DIALOG_CAPTURE);
        }
    });

    findViewById(R.id.bZoomIn).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            wv.ZoomInSelection();
        }
    });

    findViewById(R.id.bZoomOut).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            wv.ZoomOutSelection();
        }
    });

    setNavButtonState(NavButtonState.NBS_GO);

    progressBar = (ProgressBar) findViewById(R.id.progressbar);

    //CookieSyncManager.createInstance(this);

    //webSettings.setLoadsImagesAutomatically(imgOn);
    userMail = prefs.getString("userMail", "");
    userPass = prefs.getString("userPass", "");
    sessionId = prefs.getString("sessionId", "");

    appSettings.sessionId = sessionId;
    appSettings.userMail = userMail;
    appSettings.userPass = userPass;

    if ("1".equals(prefs.getString("userAgent", "1"))) {
        wv.setUserAgent(null);
    } else
        wv.setUserAgent(deskAgent);

    final Activity activity = this;
    //lastUrl="file:///android_asset/android.html";
    if (lastUrl.length() > 0) {
        //wv.navigate(lastUrl);

        //if(!urlField.getText().toString().equals(wv.getUrl()))
        urlField.setText(lastUrl);
        openURL();
    }
    isInitNow = false;

    urlField.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            // TODO Auto-generated method stub
            /*String item = (String)parent.getItemAtPosition(position);
                    
            Toast.makeText(
                  getApplicationContext(),
                  "  "
                + item,
                  Toast.LENGTH_SHORT).show();*/
            openURL();

        }
    });

    urlField.addTextChangedListener(this);
    parent = prefs.getString("remFolderId", "default");

    /*ListView listView = (ListView) findViewById(R.id.left_drawer);
    listView.setAdapter(new DrawerMenuAdapter(this,getResources().getStringArray(R.array.lmenu_browser)));
    listView.setOnItemClickListener(this);*/
}

From source file:com.alley.android.ppi.app.DetailFragment.java

private Intent createSharePropertyIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mPropertyDescription + PROPERTY_PRICE_SHARE_HASHTAG);
    return shareIntent;
}

From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java

@Override
public void create() {
    try {/*from ww  w .j av  a2 s . c o  m*/
        setContentView(R.layout.grouped_contacts_details);

        Intent currentIntent = getIntent();
        Bundle store = currentIntent.getExtras();
        widget = (Widget) store.getSerializable("Widget");
        if (widget == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }

        person = (Person) store.getSerializable("person");
        if (person == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }
        setTopBarTitle(widget.getTitle());

        Boolean single = currentIntent.getBooleanExtra("single", true);

        setTopBarLeftButtonTextAndColor(
                single ? getResources().getString(R.string.common_home_upper)
                        : getResources().getString(R.string.common_back_upper),
                getResources().getColor(android.R.color.black), true, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        finish();
                    }
                });
        setTopBarTitleColor(getResources().getColor(android.R.color.black));
        setTopBarBackgroundColor(Statics.color1);

        if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) {

            ImageView shareButton = (ImageView) getLayoutInflater()
                    .inflate(R.layout.grouped_contacts_share_button, null);
            shareButton.setLayoutParams(
                    new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density),
                            (int) (39 * getResources().getDisplayMetrics().density)));
            shareButton.setColorFilter(Color.BLACK);
            setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share),
                    new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder();

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                                sharingDialogBuilder
                                        .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();
                                                Intent email = new Intent(Intent.ACTION_SEND);
                                                email.putExtra(Intent.EXTRA_TEXT, message);
                                                email.setType("message/rfc822");
                                                startActivity(Intent.createChooser(email,
                                                        getString(R.string.choose_email_client)));
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                                sharingDialogBuilder
                                        .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();

                                                try {
                                                    Utils.sendSms(ContactDetailsActivity.this, message);
                                                } catch (ActivityNotFoundException e) {
                                                    e.printStackTrace();
                                                }
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT)))
                                sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook,
                                        R.drawable.gc_add_to_contacts, true,
                                        new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                createNewContact(person.getName(), person.getPhone(),
                                                        person.getEmail());
                                            }
                                        });

                            showDialogSharing(sharingDialogBuilder.build());
                        }
                    });

        }

        boolean hasSchema = store.getBoolean("hasschema");
        cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder();

        contacts = person.getContacts();

        if (widget.getTitle().length() > 0) {
            setTitle(widget.getTitle());
        }

        root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root);

        if (hasSchema) {
            root.setBackgroundColor(Statics.color1);
        } else if (widget.isBackgroundURL()) {
            cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL());
            File backgroundFile = new File(cacheBackgroundFile);
            if (backgroundFile.exists()) {
                root.setBackgroundDrawable(
                        new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile))));
            } else {
                BackgroundDownloadTask dt = new BackgroundDownloadTask();
                dt.execute(widget.getBackgroundURL());
            }
        } else if (widget.isBackgroundInAssets()) {
            AssetManager am = this.getAssets();
            root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL())));
        }

        if (contacts != null) {
            ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar);

            avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            if (person.hasAvatar() && NetworkUtils.isOnline(this)) {
                avatarImage.setVisibility(View.VISIBLE);
                Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar)
                        .dontAnimate().into(avatarImage);
            } else {
                avatarImage.setVisibility(View.VISIBLE);
                avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            }

            String name = "";
            neededContacts = new ArrayList<>();
            for (Contact con : contacts) {
                if ((con.getType() == 5) || (con.getDescription().length() == 0)) {
                } else {
                    if (con.getType() == 0) {
                        name = con.getDescription();
                    } else
                        neededContacts.add(con);
                }
            }

            if (neededContacts.isEmpty()) {
                handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA);
                return;
            }

            headSeparator = findViewById(R.id.gc_head_separator);
            bottomSeparator = findViewById(R.id.gc_bottom_separator);
            imageBottom = findViewById(R.id.gc_image_bottom_layout);
            personName = (TextView) findViewById(R.id.gc_details_description);

            if ("".equals(name))
                personName.setVisibility(View.GONE);
            else {
                personName.setVisibility(View.VISIBLE);
                personName.setText(name);
                personName.setTextColor(Statics.color3);
            }
            if (Statics.isLight) {
                headSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
            } else {
                headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
            }

            ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1);

            ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view);
            list.setDivider(null);

            ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this,
                    R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1));
            list.setAdapter(adapter);
            list.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
                    listViewItemClick(position);
                }
            });
        }

        if (widget.hasParameter("add_contact")) {
            HashMap<String, String> hm = new HashMap<>();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    hm.put("contactName", contacts.get(i).getDescription());
                }
                    break;
                case 1: {
                    hm.put("contactNumber", contacts.get(i).getDescription());
                }
                    break;
                case 2: {
                    hm.put("contactEmail", contacts.get(i).getDescription());
                }
                    break;
                case 3: {
                    hm.put("contactSite", contacts.get(i).getDescription());
                }
                    break;
                }
            }
            addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm);
        }
        if (widget.hasParameter("send_sms")) {
            HashMap<String, String> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                sb.append(contacts.get(i).getDescription());
                if (i < contacts.size() - 1) {
                    sb.append(", ");
                }
            }
            hm.put("text", sb.toString());
            addNativeFeature(NATIVE_FEATURES.SMS, null, hm);
        }
        if (widget.hasParameter("send_mail")) {
            HashMap<String, CharSequence> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    sb.append("Name: ");
                }
                    break;
                case 1: {
                    sb.append("Phone: ");
                }
                    break;
                case 2: {
                    sb.append("Email: ");
                }
                    break;
                case 3: {
                    sb.append("Site: ");
                }
                    break;
                case 4: {
                    sb.append("Address: ");
                }
                    break;
                }
                sb.append(contacts.get(i).getDescription());
                sb.append("<br/>");
            }

            if (widget.isHaveAdvertisement()) {
                sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)");
            }

            hm.put("text", sb.toString());
            hm.put("subject", "Contacts");
            addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm);
        }

    } catch (Exception e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.albedinsky.android.support.intent.ShareIntent.java

/**
 *//*from   ww w.ja va 2  s.  co m*/
@NonNull
@Override
protected Intent onBuild() {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType(mDataType);
    if (!TextUtils.isEmpty(mTitle)) {
        intent.putExtra(Intent.EXTRA_TITLE, mTitle);
    }
    if (!TextUtils.isEmpty(mContent)) {
        intent.putExtra(Intent.EXTRA_TEXT, mContent);
    }
    if (mUri != null) {
        intent.putExtra(Intent.EXTRA_STREAM, mUri);
    } else if (mUris != null) {
        intent.setAction(Intent.ACTION_SEND_MULTIPLE);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(mUris));
    }
    return intent;
}

From source file:com.aqtx.app.main.activity.MainActivity.java

private Intent getDefaultIntent() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/*");
    return intent;
}

From source file:com.zia.freshdocs.widget.adapter.CMISAdapter.java

/**
 * Send the content using a built-in Android activity which can handle the
 * content type.//from  w  ww.j a v  a2  s  .co m
 * 
 * @param position
 */
public void shareContent(int position) {
    final NodeRef ref = getItem(position);
    downloadContent(ref, new Handler() {
        public void handleMessage(Message msg) {
            Context context = getContext();
            boolean done = msg.getData().getBoolean("done");

            if (done) {
                dismissProgressDlg();

                File file = (File) mDlThread.getResult();

                if (file != null) {
                    Resources res = context.getResources();
                    Uri uri = Uri.fromFile(file);
                    Intent emailIntent = new Intent(Intent.ACTION_SEND);
                    emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, ref.getName());
                    emailIntent.putExtra(Intent.EXTRA_TEXT, res.getString(R.string.email_text));
                    emailIntent.setType(ref.getContentType());

                    try {
                        context.startActivity(
                                Intent.createChooser(emailIntent, res.getString(R.string.email_title)));
                    } catch (ActivityNotFoundException e) {
                        String text = "No suitable applications registered to send " + ref.getContentType();
                        int duration = Toast.LENGTH_SHORT;
                        Toast toast = Toast.makeText(context, text, duration);
                        toast.show();
                    }
                }
            } else {
                int value = msg.getData().getInt("progress");
                if (value > 0) {
                    mProgressDlg.setProgress(value);
                }
            }
        }
    });
}

From source file:ca.rmen.android.poetassistant.main.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    Log.d(TAG, "onNewIntent() called with: " + "intent = [" + intent + "]");
    setIntent(intent);/*from ww  w .  j  a va2  s .  c  o  m*/
    // The user entered a search term either by typing or by voice
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getDataString();
        if (TextUtils.isEmpty(query)) {
            query = intent.getStringExtra(SearchManager.QUERY);
        }
        if (TextUtils.isEmpty(query)) {
            CharSequence userQuery = intent.getCharSequenceExtra(SearchManager.USER_QUERY);
            if (!TextUtils.isEmpty(userQuery))
                query = userQuery.toString();
        }
        if (TextUtils.isEmpty(query))
            return;
        mSearch.addSuggestions(query);
        mSearch.search(query);
    }
    // We got here from a deep link
    else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri data = getIntent().getData();
        handleDeepLink(data);
    }
    // Play some text in the tts tab
    else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        mBinding.viewPager.setCurrentItem(mPagerAdapter.getPositionForTab(Tab.READER));
        String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
        ReaderFragment readerFragment = (ReaderFragment) mPagerAdapter.getFragment(mBinding.viewPager,
                Tab.READER);
        readerFragment.setText(sharedText);
    }
}

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();//  w w  w.  j  av a  2  s . co 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);
    }
}