Android 实现微信,微博,微信朋友圈,QQ分享的功能

时间:2021-05-21

Android 实现微信,微博,微信朋友圈,QQ分享的功能

一、去各自所在的开发者平台注册相应的Key值;引入相关jar包、权限等

二、ShareUtil工具类

import android.app.Activity;import android.content.Context;import android.content.pm.PackageInfo;import android.content.pm.PackageManager;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.os.Bundle;import com.sina.weibo.sdk.api.ImageObject;import com.sina.weibo.sdk.api.TextObject;import com.sina.weibo.sdk.api.WeiboMultiMessage;import com.sina.weibo.sdk.api.share.IWeiboShareAPI;import com.sina.weibo.sdk.api.share.SendMultiMessageToWeiboRequest;import com.sina.weibo.sdk.api.share.WeiboShareSDK;import com.sina.weibo.sdk.auth.AuthInfo;import com.sina.weibo.sdk.auth.Oauth2AccessToken;import com.sina.weibo.sdk.auth.WeiboAuthListener;import com.sina.weibo.sdk.exception.WeiboException;import com.tencent.connect.share.QQShare;import com.tencent.mm.sdk.modelmsg.SendMessageToWX;import com.tencent.mm.sdk.modelmsg.WXMediaMessage;import com.tencent.mm.sdk.modelmsg.WXWebpageObject;import com.tencent.mm.sdk.openapi.IWXAPI;import com.tencent.mm.sdk.openapi.WXAPIFactory;import com.tencent.tauth.IUiListener;import com.tencent.tauth.Tencent;import java.util.List;import cn.hnshangyu.maker.R;import cn.hnshangyu.maker.weibo.AccessTokenKeeper;import cn.hnshangyu.maker.weibo.Constants;/** * ============================================ * 文件名:ShareUtil.java * 日期:2016-08-17 14:58 * 描述:分享帮助类 * 版本:1.0 * * ============================================ */public class ShareUtil { /** * 微博微博分享接口实例 */ public static IWeiboShareAPI mWeiboShareAPI; //微信分享 public static final String WEIXIN_SHARE_APP_ID = "wx0c********88488d"; public static IWXAPI weixin_api; public static final String QQ_APP_ID = "11****5659"; public static Tencent mTencent; public static void shareQQ(Activity activity, String sharePath, IUiListener listener) { //qq分享 mTencent = Tencent.createInstance(QQ_APP_ID, activity); if (isQQClientAvailable(activity)) {// String content = activity.getResources().getString(R.string.ivQrcode_content); final Bundle params = new Bundle(); params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT); params.putString(QQShare.SHARE_TO_QQ_TITLE, "######"); params.putString(QQShare.SHARE_TO_QQ_SUMMARY, "#############..."); params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, sharePath);// params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, "https:///wiki/Scope */ public static final String SCOPE = "email,direct_messages_read,direct_messages_write," + "friendships_groups_read,friendships_groups_write,statuses_to_me_read," + "follow_app_official_microblog," + "invitation_write";}

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章