The Android system provides the sharing function (text and images can be shared at the same time ),

Source: Internet
Author: User

The Android system provides the sharing function (text and images can be shared at the same time ),
Zookeeper

/*** Sharing Function ** @ param context * @ param activityTitle * Activity name * @ param msgTitle * Message Title * @ param msgText * message content * @ param imgPath * image path, if you do not share an image, pass null */public void shareMsg (String activityTitle, String msgTitle, String msgText, String imgPath) {Intent intent = new Intent (Intent. ACTION_SEND); if (imgPath = null | imgPath. equals ("") {intent. setType ("text/plain"); // plain text} else {File f = New File (imgPath); if (f! = Null & f. exists () & f. isFile () {intent. setType ("image/jpg"); Uri u = Uri. fromFile (f); intent. putExtra (Intent. EXTRA_STREAM, u) ;}} intent. putExtra (Intent. EXTRA_SUBJECT, msgTitle); intent. putExtra (Intent. EXTRA_TEXT, msgText); intent. setFlags (Intent. FLAG_ACTIVITY_NEW_TASK); startActivity (Intent. createChooser (intent, activityTitle ));}
Simple and Easy to use!




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.