Android Open Source - CommonLibs Share Utils






From Project

Back to project page CommonLibs.

License

The source code is released under:

Apache License

If you think the Android project CommonLibs listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.alex.common.utils;
/*  www .j  av  a  2s  .com*/
import java.io.File;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;

/**
 * ?????
 * @author caisenchuan
 */
public class ShareUtils {
    /*--------------------------
     * ???
     *-------------------------*/

    /*--------------------------
     * ?????????
     *-------------------------*/

    /*--------------------------
     * ??
     *-------------------------*/

    /*--------------------------
     * public??
     *-------------------------*/
    /**
     * ????
     * @param context
     * @param msgTitle
     * @param msgText
     * @param imgPath
     */
    public static void share(Context context,
                             String msgTitle,
                             String msgText,
                             String imgPath) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        
        if (TextUtils.isEmpty(imgPath)) {
            intent.setType("text/plain"); // ???
        } else {
            File f = new File(imgPath);
            if (f != null && f.exists() && f.isFile()) {
                intent.setType("image/*");
                Uri u = Uri.fromFile(f);
                intent.putExtra(Intent.EXTRA_STREAM, u);
            }
        }
        
        String activityTitle = "Share";
        
        intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
        intent.putExtra(Intent.EXTRA_TEXT, msgText);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        
        context.startActivity(Intent.createChooser(intent, activityTitle));
    }
    
    /*--------------------------
     * protected??
     *-------------------------*/

    /*--------------------------
     * private??
     *-------------------------*/
}




Java Source Code List

com.alex.common.AppConfig.java
com.alex.common.AppControl.java
com.alex.common.Err.java
com.alex.common.OnHttpRequestReturnListener.java
com.alex.common.activities.BaseActivity.java
com.alex.common.activities.ImageLoadActivity.java
com.alex.common.activities.WebViewActivity.java
com.alex.common.apis.HttpApi.java
com.alex.common.exception.RetErrorException.java
com.alex.common.utils.BackgroundHandler.java
com.alex.common.utils.BaiduMapUtils.java
com.alex.common.utils.DateTimeUtils.java
com.alex.common.utils.DeviceUtils.java
com.alex.common.utils.DialogUtils.java
com.alex.common.utils.FileUtils.java
com.alex.common.utils.ImageUtils.java
com.alex.common.utils.KLog.java
com.alex.common.utils.Misc.java
com.alex.common.utils.NetworkUtils.java
com.alex.common.utils.PrefUtils.java
com.alex.common.utils.ShareUtils.java
com.alex.common.utils.StringUtils.java
com.alex.common.utils.ThreadUtils.java
com.alex.common.utils.ToastUtils.java
com.alex.common.views.ZoomImageView.java