1
.接入时要注意:appid和key等ios和安卓是分开的,不要搞错了
2.这是分享各个平台的写法
case R.id.
share_weixin:
WechatHelper.ShareParams Wechatsp = new Wechat.ShareParams() ;
Wechatsp. title = title ;
Wechatsp. text = content ;
Wechatsp. imageUrl = image ;
Wechatsp. url = url ;
Wechatsp.setShareType(Platform. SHARE_WEBPAGE) ;
Platform Wechatplatform = ShareSDK. getPlatform(Wechat. NAME) ;
Wechatplatform.share(Wechatsp) ;
break;
case R.id. share_friends:
WechatMoments.ShareParams WechatMomentsp = new WechatMoments.ShareParams() ;
WechatMomentsp. title = title ;
WechatMomentsp. text = content ;
WechatMomentsp. imageUrl = image ;
WechatMomentsp. url = url ;
WechatMomentsp.setShareType(Platform. SHARE_WEBPAGE) ;
Platform WechatMomentplatform = ShareSDK. getPlatform(WechatMoments. NAME) ;
WechatMomentplatform.share(WechatMomentsp) ;
break;
case R.id. share_qq:
QQ.ShareParams QQsp = new QQ.ShareParams() ;
QQsp. title = title ;
QQsp. text = content ;
QQsp. imageUrl = image ;
QQsp. titleUrl = url ;
Platform qqplatform = ShareSDK. getPlatform(QQ. NAME) ;
qqplatform.share(QQsp) ;
break;
case R.id. share_qzone:
QZone.ShareParams qqzonesp = new QZone.ShareParams() ;
qqzonesp. title = title ;
qqzonesp. text = content ;
qqzonesp. imageUrl = image ;
qqzonesp. titleUrl = url ;
Platform qqzoneplatform = ShareSDK. getPlatform(QZone. NAME) ;
qqzoneplatform.share(qqzonesp) ;
break;
case R.id. share_weibo:
SinaWeibo.ShareParams SinaWeibosp = new SinaWeibo.ShareParams() ;
SinaWeibosp.setText( content) ;
SinaWeibosp.setImagePath( image) ;
SinaWeibosp.setUrl( url) ;
SinaWeibosp.setTitle( title) ;
Platform weibo = ShareSDK. getPlatform(SinaWeibo. NAME) ;
weibo.setPlatformActionListener( new PlatformActionListener() {
@Override
public void onComplete(Platform platform , int i , HashMap<String , Object> hashMap) {
}
@Override
public void onError(Platform platform , int i , Throwable throwable) {
}
@Override
public void onCancel(Platform platform , int i) {
}
}) ; // 设置分享事件回调
WechatHelper.ShareParams Wechatsp = new Wechat.ShareParams() ;
Wechatsp. title = title ;
Wechatsp. text = content ;
Wechatsp. imageUrl = image ;
Wechatsp. url = url ;
Wechatsp.setShareType(Platform. SHARE_WEBPAGE) ;
Platform Wechatplatform = ShareSDK. getPlatform(Wechat. NAME) ;
Wechatplatform.share(Wechatsp) ;
break;
case R.id. share_friends:
WechatMoments.ShareParams WechatMomentsp = new WechatMoments.ShareParams() ;
WechatMomentsp. title = title ;
WechatMomentsp. text = content ;
WechatMomentsp. imageUrl = image ;
WechatMomentsp. url = url ;
WechatMomentsp.setShareType(Platform. SHARE_WEBPAGE) ;
Platform WechatMomentplatform = ShareSDK. getPlatform(WechatMoments. NAME) ;
WechatMomentplatform.share(WechatMomentsp) ;
break;
case R.id. share_qq:
QQ.ShareParams QQsp = new QQ.ShareParams() ;
QQsp. title = title ;
QQsp. text = content ;
QQsp. imageUrl = image ;
QQsp. titleUrl = url ;
Platform qqplatform = ShareSDK. getPlatform(QQ. NAME) ;
qqplatform.share(QQsp) ;
break;
case R.id. share_qzone:
QZone.ShareParams qqzonesp = new QZone.ShareParams() ;
qqzonesp. title = title ;
qqzonesp. text = content ;
qqzonesp. imageUrl = image ;
qqzonesp. titleUrl = url ;
Platform qqzoneplatform = ShareSDK. getPlatform(QZone. NAME) ;
qqzoneplatform.share(qqzonesp) ;
break;
case R.id. share_weibo:
SinaWeibo.ShareParams SinaWeibosp = new SinaWeibo.ShareParams() ;
SinaWeibosp.setText( content) ;
SinaWeibosp.setImagePath( image) ;
SinaWeibosp.setUrl( url) ;
SinaWeibosp.setTitle( title) ;
Platform weibo = ShareSDK. getPlatform(SinaWeibo. NAME) ;
weibo.setPlatformActionListener( new PlatformActionListener() {
@Override
public void onComplete(Platform platform , int i , HashMap<String , Object> hashMap) {
}
@Override
public void onError(Platform platform , int i , Throwable throwable) {
}
@Override
public void onCancel(Platform platform , int i) {
}
}) ; // 设置分享事件回调
weibo.share(SinaWeibosp);
3.注意一个坑
当项目里面自带有微信原生的activity时,需要合并
public class
WXEntryActivity
extends WechatHandlerActivity
implements IWXAPIEventHandler {
这里的WXEntryActivit是微信原生自带要求的,并且要实现IWXAPIEventHandler的接口,但是,mob要求的WXEntryActivit是需要继承自WechatHandlerActivity的,所以需要合并,并且实现重写里面的方法