cn.sharesdk.wechat.moments.WechatMoments Java Examples

The following examples show how to use cn.sharesdk.wechat.moments.WechatMoments. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From ShareSDKShareDifMsgDemo-Android with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
	switch (v.getId()) {
	case R.id.btn_sms://短信分享
		showShare(true, ShortMessage.NAME);
		break;
	case R.id.btn_sina://新浪分享
		showShare(true, SinaWeibo.NAME);			
		break;
	case R.id.btn_tencent://腾讯分享
		showShare(true, TencentWeibo.NAME);			
		break;			
	case R.id.btn_wechatmoment://朋友圈分享
		showShare(true, WechatMoments.NAME);			
		break;			
	default:
		break;
	}
}
 
Example #2
Source File: NewsDetailActivity.java    From LiuAGeAndroid with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.ib_news_detail_bottom_bar_back:
            finish();
            break;
        case R.id.ib_news_detail_bottom_bar_edit:
            showCommentDialog();
            break;
        case R.id.ib_news_detail_bottom_bar_font:
            showSetFontDialog();
            break;
        case R.id.ib_news_detail_bottom_bar_collection:
            collectArticle();
            break;
        case R.id.ib_news_detail_bottom_bar_share:
            // 弹出分享ui
            showShare(null);
            break;
        case R.id.ll_article_content_share_qq:
            // qq分享
            showShare(ShareSDK.getPlatform(QQ.NAME).getName());
            break;
        case R.id.ll_article_content_share_weixin:
            // 微信分享
            showShare(ShareSDK.getPlatform(Wechat.NAME).getName());
            break;
        case R.id.ll_article_content_share_pyq:
            // 朋友圈分享
            showShare(ShareSDK.getPlatform(WechatMoments.NAME).getName());
            break;
        case R.id.iv_news_detail_ad_image:
            didTappedAdImageView();
            break;
    }
}
 
Example #3
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareWebpager(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setFilePath(ResourcesManager.getInstace(MobSDK.getContext()).getFilePath());
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setUrl(ResourcesManager.getInstace(MobSDK.getContext()).getUrl());
	shareParams.setImageData(ResourcesManager.getInstace(MobSDK.getContext()).getImageBmp());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setShareType(Platform.SHARE_WEBPAGE);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #4
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareVideo(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setFilePath(ResourcesManager.getInstace(MobSDK.getContext()).getFilePath());
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setUrl(ResourcesManager.getInstace(MobSDK.getContext()).getUrl());
	shareParams.setShareType(Platform.SHARE_VIDEO);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #5
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareMusic(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setImageUrl(ResourcesManager.getInstace(MobSDK.getContext()).getImageUrl());
	shareParams.setUrl(ResourcesManager.getInstace(MobSDK.getContext()).getUrl());
	shareParams.setMusicUrl(ResourcesManager.getInstace(MobSDK.getContext()).getMusicUrl());
	shareParams.setShareType(Platform.SHARE_MUSIC);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #6
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareImage(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setImageUrl(ResourcesManager.getInstace(MobSDK.getContext()).getImageUrl());
	shareParams.setImageData(ResourcesManager.getInstace(MobSDK.getContext()).getImageBmp());
	shareParams.setShareType(Platform.SHARE_IMAGE);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #7
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareText(PlatformActionListener mListener){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setShareType(Platform.SHARE_TEXT);
	platform.setPlatformActionListener(mListener);
	platform.share(shareParams);
}
 
Example #8
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareWebpager(){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setFilePath(ResourcesManager.getInstace(MobSDK.getContext()).getFilePath());
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setUrl(LINK_URL);//ResourcesManager.getInstace(MobSDK.getContext()).getUrl()
	shareParams.setImageData(ResourcesManager.getInstace(MobSDK.getContext()).getImageBmp());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setShareType(Platform.SHARE_WEBPAGE);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #9
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareVideo(){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setUrl(ResourcesManager.getInstace(MobSDK.getContext()).getUrl());
	shareParams.setImageUrl("https://t3.ftcdn.net/jpg/02/01/25/00/240_F_201250053_xMFe9Hax6w01gOiinRLEPX0Wt1zGCzYz.jpg");
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setShareType(Platform.SHARE_VIDEO);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #10
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareMusic(){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setImageUrl("https://t3.ftcdn.net/jpg/02/01/25/00/240_F_201250053_xMFe9Hax6w01gOiinRLEPX0Wt1zGCzYz.jpg");
	shareParams.setUrl(ResourcesManager.getInstace(MobSDK.getContext()).getUrl());
	shareParams.setMusicUrl(ResourcesManager.getInstace(MobSDK.getContext()).getMusicUrl());
	shareParams.setShareType(Platform.SHARE_MUSIC);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #11
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareImage(){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setImagePath(ResourcesManager.getInstace(MobSDK.getContext()).getImagePath());
	shareParams.setImageUrl(ResourcesManager.getInstace(MobSDK.getContext()).getImageUrl());
	shareParams.setImageData(ResourcesManager.getInstace(MobSDK.getContext()).getImageBmp());
	shareParams.setShareType(Platform.SHARE_IMAGE);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #12
Source File: WechatMomentsShare.java    From ShareSDK-for-Android with MIT License 5 votes vote down vote up
public void shareText(){
	Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
	Platform.ShareParams shareParams = new  Platform.ShareParams();
	shareParams.setText(ResourcesManager.getInstace(MobSDK.getContext()).getText());
	shareParams.setTitle(ResourcesManager.getInstace(MobSDK.getContext()).getTitle());
	shareParams.setShareType(Platform.SHARE_TEXT);
	platform.setPlatformActionListener(platformActionListener);
	platform.share(shareParams);
}
 
Example #13
Source File: InitUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public static void initShareSDK(Context context) {

        ShareSDK.initSDK(context, true);

        HashMap<String, Object> hashMap1 = new HashMap<String, Object>();
        hashMap1.put("Id", 1);
        hashMap1.put("Enable", ClanUtils.isUseShareSDKPlatformName(context, SinaWeibo.NAME) + "");
        ShareSDK.setPlatformDevInfo(Wechat.NAME, hashMap1);

//        HashMap<String, Object> hashMap3 = new HashMap<String, Object>();
//        hashMap3.put("Id", 6);
//        hashMap3.put("Enable", ClanUtils.isUseShareSDKPlatformName(context, QQ.NAME) + "");
//        ShareSDK.setPlatformDevInfo("QZone", hashMap3);

        HashMap<String, Object> hashMap4 = new HashMap<String, Object>();
        hashMap4.put("Id", 4);
        hashMap4.put("Enable", ClanUtils.isUseShareSDKPlatformName(context, Wechat.NAME) + "");
        ShareSDK.setPlatformDevInfo(Wechat.NAME, hashMap4);

        HashMap<String, Object> hashMap5 = new HashMap<String, Object>();
        hashMap5.put("Id", 5);
        hashMap5.put("Enable", ClanUtils.isUseShareSDKPlatformName(context, Wechat.NAME) + "");
        ShareSDK.setPlatformDevInfo(WechatMoments.NAME, hashMap5);

//        HashMap<String, Object> hashMap6 = new HashMap<String, Object>();
//        hashMap6.put("Id", 6);
//        hashMap6.put("Enable", ClanUtils.isUseShareSDKPlatformName(context, Wechat.NAME) + "");
//        ShareSDK.setPlatformDevInfo(WechatFavorite.NAME, hashMap6);

//        HashMap<String, Object> hashMap7 = new HashMap<String, Object>();
//        hashMap7.put("Id", 7);
//        hashMap7.put("Enable", ClanUtils.isUseShareSDKPlatformName(context, QQ.NAME) + "");
//        ShareSDK.setPlatformDevInfo(QQ.NAME, hashMap7);


    }
 
Example #14
Source File: NewsDetailActivity.java    From BaoKanAndroid with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.ib_news_detail_bottom_bar_back:
            finish();
            break;
        case R.id.ib_news_detail_bottom_bar_edit:
            showCommentDialog();
            break;
        case R.id.ib_news_detail_bottom_bar_font:
            showSetFontDialog();
            break;
        case R.id.ib_news_detail_bottom_bar_collection:
            collectArticle();
            break;
        case R.id.ib_news_detail_bottom_bar_share:
            // 弹出分享ui
            showShare(null);
            break;
        case R.id.ll_article_content_share_qq:
            // qq分享
            showShare(ShareSDK.getPlatform(QQ.NAME).getName());
            break;
        case R.id.ll_article_content_share_weixin:
            // 微信分享
            showShare(ShareSDK.getPlatform(Wechat.NAME).getName());
            break;
        case R.id.ll_article_content_share_pyq:
            // 朋友圈分享
            showShare(ShareSDK.getPlatform(WechatMoments.NAME).getName());
            break;
    }
}
 
Example #15
Source File: PlatformAuthorizeUserInfoManager.java    From ShareSDK-for-Android with MIT License 4 votes vote down vote up
public void whatMomentsAuthorize() {
	Platform moments = ShareSDK.getPlatform(WechatMoments.NAME);
	doAuthorize(moments);
}
 
Example #16
Source File: ShareUtils.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
public static SharePopupWindow showShare(Context context, View showAt, String title, String text, String imageurl, String url, PlatformActionListener platformActionListener) {
    ZogUtils.printError(ThreadDetailActivity.class, "showShare imageurl:" + imageurl);

    ArrayList<ShareItem> items = new ArrayList<>();
    if (ClanUtils.isUseShareSDKPlatformName(context, Wechat.NAME)) {
        ShareItem shareItem0 = new ShareItem(Wechat.NAME, context.getResources().getDrawable(R.drawable.sns_weixin_icon), "微信好友");
        ShareItem shareItem1 = new ShareItem(WechatMoments.NAME, context.getResources().getDrawable(R.drawable.sns_weixin_timeline_icon), "朋友圈");
        items.add(shareItem0);
        items.add(shareItem1);
    }

    if (ClanUtils.isUseShareSDKPlatformName(context, SinaWeibo.NAME)) {
        ShareItem shareItem2 = new ShareItem(SinaWeibo.NAME, context.getResources().getDrawable(R.drawable.sns_sina_icon), "新浪微博");
        items.add(shareItem2);

    }

    if (ClanUtils.isUseShareSDKPlatformName(context, "QQ")) {
        ShareItem shareItem3 = new ShareItem("QQ", context.getResources().getDrawable(R.drawable.sns_qqfriends_icon), "QQ");
        ShareItem shareItem4 = new ShareItem("QZone", context.getResources().getDrawable(R.drawable.sns_qzone_icon), "QQ空间");
        items.add(shareItem3);
        items.add(shareItem4);
    }

    ShareItem shareItem5 = new ShareItem("Copy", context.getResources().getDrawable(R.drawable.sns_copy_icon), "复制链接");
    items.add(shareItem5);

    ShareModel model = new ShareModel();
    model.setImageUrl(imageurl);
    model.setText(text);
    model.setTitle(title);
    model.setUrl(url);


    SharePopupWindow share = SharePopupWindow.init(context, items, model);
    share.setPlatformActionListener(platformActionListener);
    share.setOnItemClickListener(new ShareItemClickListener(share));
    share.showAtLocation(showAt,
            Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);

    return  share;
}
 
Example #17
Source File: ShareUtil.java    From CatchPiggy with GNU General Public License v3.0 4 votes vote down vote up
public static void shareToWeChatMoments(Context context, boolean isRequestHelp, String message) {
    OnekeyShare onekeyShare = getData(context, isRequestHelp, message);
    onekeyShare.setPlatform(WechatMoments.NAME);
    onekeyShare.show(context);
}
 
Example #18
Source File: MainActivity.java    From -Android_ShareSDK_Example_Wechat with MIT License 4 votes vote down vote up
@Override
public void onClick(View v) {
	
	if(v.getId() == R.id.button1){
		//快捷分享,没有九宫格,只有编辑页
		//Using onekeyshare library to share wechat
		OnekeyShare oks = new OnekeyShare();			
		// 分享时Notification的图标和文字
		//Settig the notification of picture and content on the status bar when share successfully
		oks.setNotification(R.drawable.ic_launcher, "Gtpass");			
		//设置默认微博平台,例如腾讯微博的,可以是TencentWeibo.NAME
		//Setting the share platform
		//If it is not been setted, that will show the Nine Grid Palace
		oks.setPlatform(Wechat.NAME);
		//分享纯文本
		//微信分享必须要有text和title这两个参数
		//不同的分享类型,分享参数不一样,可以参考sample中wechatpage这个类
		//参数文档:http://sharesdk.cn/androidDoc/index.html?cn/sharesdk/framework/Platform.html
		//Share the text and title to a wechat friend
		//the document of the params are required when wechat share,http://sharesdk.cn/androidDoc/index.html?cn/sharesdk/framework/Platform.html
		oks.setText("ShareSDK share text");
		oks.setTitle("ShareSDK share title");			
		oks.setSilent(true);
		oks.show(MainActivity.this);	
		
	}else if (v.equals(ctvStWm)) {
		//微信朋友圈,wechat moment
		ctvStWm.setChecked(!ctvStWm.isChecked());
		findViewById(R.id.btnApp).setVisibility(ctvStWm.isChecked() ? View.GONE : View.VISIBLE);
		findViewById(R.id.btnAppExt).setVisibility(ctvStWm.isChecked() ? View.GONE : View.VISIBLE);
		findViewById(R.id.btnFile).setVisibility(ctvStWm.isChecked() ? View.GONE : View.VISIBLE);
		return;
		
	}else{
		//微信好友,wechat friend
		String name = ctvStWm.isChecked() ? WechatMoments.NAME : Wechat.NAME;
		Platform plat = ShareSDK.getPlatform(MainActivity.this, name);
		plat.setPlatformActionListener(this);
		ShareParams sp = ctvStWm.isChecked() ? getWechatMomentsShareParams(v) : getWechatShareParams(v);
		plat.share(sp);
		
	}
}
 
Example #19
Source File: MainActivity.java    From -Android_ShareSDK_Example_Wechat with MIT License 4 votes vote down vote up
/**微信朋友圈分享参数
 * 
 * WechatMoment share params
 * */
private ShareParams getWechatMomentsShareParams(View v) {
	WechatMoments.ShareParams sp = new WechatMoments.ShareParams();
	//任何分享类型都需要title和text, the two params of title and text are required in every share type
	sp.title = "ShareSDK wechatmoment title";
	sp.text = "ShareSDK wechatmoment text";
	sp.shareType = Platform.SHARE_TEXT;
	switch (v.getId()) {
		case R.id.btnUpload: {//分享sdcard中的图片, share the sdcard's picture
			sp.shareType = Platform.SHARE_IMAGE;
			sp.imagePath = MainActivity.TEST_IMAGE;
		}
		break;
		case R.id.btnUploadBm: {//分享drawable中的图片,share the picture on the drawable
			sp.shareType = Platform.SHARE_IMAGE;
			sp.imageData = BitmapFactory.decodeResource(v.getResources(), R.drawable.ic_launcher);
		}
		break;
		case R.id.btnUploadUrl: {//分享网络图片,share the picture from the web
			sp.shareType = Platform.SHARE_IMAGE;
			sp.imageUrl = "http://img.appgo.cn/imgs/sharesdk/content/2013/07/16/1373959974649.png";
		}
		break;
		case R.id.btnMusic: {//分享网络音乐, share music
			sp.shareType = Platform.SHARE_MUSIC;
			sp.musicUrl = "http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3";
			sp.url = "http://sharesdk.cn";
			sp.imagePath = MainActivity.TEST_IMAGE;
		}
		break;
		case R.id.btnVideo: {//分享网络视频,share video
			sp.shareType = Platform.SHARE_VIDEO;
			sp.url = "http://t.cn/zT7cZAo";
			sp.imagePath = MainActivity.TEST_IMAGE;
		}
		break;
		case R.id.btnWebpage: {//图文分享,网页形式,sdcard中的图片,share webpage with a picture from the sdcard
			sp.shareType = Platform.SHARE_WEBPAGE;
			sp.url = "http://t.cn/zT7cZAo";
			sp.imagePath = MainActivity.TEST_IMAGE;
		}
		break;
		case R.id.btnWebpageBm: {//图文分享,网页形式,drawable中的图片,share webpage with a picture from the drawable
			sp.shareType = Platform.SHARE_WEBPAGE;
			sp.url = "http://t.cn/zT7cZAo";
			sp.imageData = BitmapFactory.decodeResource(v.getResources(), R.drawable.ic_launcher);
		}
		break;
		case R.id.btnWebpageUrl: {//图文分享,网页形式,网页图片,share webpage with a picture from web
			sp.shareType = Platform.SHARE_WEBPAGE;
			sp.url = "http://t.cn/zT7cZAo";
			sp.imageUrl = "http://img.appgo.cn/imgs/sharesdk/content/2013/07/16/1373959974649.png";
		}
		break;
	}
	return sp;
}