/** * Sharing Function * * @param context * Context * @param activitytitle * Activity Name * @param msgtitle * Message title * @param msgtext * message content * @param Imgpath * Picture path, do not share the picture is 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, direct use!
Android system comes with sharing features (share text and pictures at the same time)