本文整理汇总了Java中cn.sharesdk.framework.ShareSDK.getPlatform方法的典型用法代码示例。如果您正苦于以下问题:Java ShareSDK.getPlatform方法的具体用法?Java ShareSDK.getPlatform怎么用?Java ShareSDK.getPlatform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.sharesdk.framework.ShareSDK
的用法示例。
在下文中一共展示了ShareSDK.getPlatform方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
public final void show(Context context) {
this.context = context;
// 显示方式是由platform和silent两个字段控制的
// 如果platform设置了,则无须显示九宫格,否则都会显示;
// 如果silent为true,表示不进入编辑页面,否则会进入。
if (shareParamsMap.containsKey("platform")) {
String name = String.valueOf(shareParamsMap.get("platform"));
Platform platform = ShareSDK.getPlatform(name);
boolean isCustomPlatform = platform instanceof CustomPlatform;
boolean isUseClientToShare = isUseClientToShare(platform);
if (silent || isCustomPlatform || isUseClientToShare) {
shareSilently(platform);
} else {
prepareForEditPage(platform);
}
} else {
showPlatformPage(context);
}
}
示例2: b
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
public static void b(Context context, b bVar) {
ShareParams shareParams = new ShareParams();
shareParams.setShareType(4);
Bitmap bitmap = null;
if (!TextUtils.isEmpty(bVar.c())) {
bitmap = BitmapFactory.decodeFile(bVar.c());
}
if (bitmap != null) {
bitmap = Bitmap.createScaledBitmap(bitmap, 150, 150, true);
} else {
bitmap = Bitmap.createScaledBitmap(Bitmap.createBitmap(150, 150, Config.ARGB_8888),
150, 150, true);
}
shareParams.setImageData(bitmap);
shareParams.setTitle(bVar.a());
shareParams.setText(bVar.b());
shareParams.setUrl(bVar.e());
Platform platform = ShareSDK.getPlatform(WechatMoments.NAME);
if (platform.isClientValid()) {
platform.share(shareParams);
return;
}
Toast.makeText(context, o.a("未安装微信或者微信版本过低。", "There is no WeChat or the version is too " +
"low."), 0).show();
c.d(o.a("未安装微信或者微信版本过低。", "There is no WeChat or the version is too low."));
}
示例3: updateUserInfoFromLocal
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
/**
* 从本地更新用户信息 - 登录成功后保存到偏好设置
*/
public void updateUserInfoFromLocal() {
// 移除第三方授权
Platform wechat = ShareSDK.getPlatform(Wechat.NAME);
if (wechat.isAuthValid()) {
wechat.removeAccount(true);
}
Platform qq = ShareSDK.getPlatform(QQ.NAME);
if (qq.isAuthValid()) {
qq.removeAccount(true);
}
// 内存缓存
UserBean.userAccount = this;
// 磁盘缓存
encode();
}
示例4: a
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
public static void a(Context context, b bVar) {
ShareParams shareParams = new ShareParams();
shareParams.setShareType(4);
Bitmap bitmap = null;
if (!TextUtils.isEmpty(bVar.c())) {
bitmap = BitmapFactory.decodeFile(bVar.c());
}
if (bitmap != null) {
bitmap = Bitmap.createScaledBitmap(bitmap, 150, 150, true);
} else {
bitmap = Bitmap.createScaledBitmap(Bitmap.createBitmap(150, 150, Config.ARGB_8888),
150, 150, true);
}
shareParams.setImageData(bitmap);
shareParams.setTitle(bVar.a());
shareParams.setText(bVar.b());
shareParams.setUrl(bVar.e());
Platform platform = ShareSDK.getPlatform(Wechat.NAME);
if (platform.isClientValid()) {
platform.share(shareParams);
return;
}
Toast.makeText(context, o.a("未安装微信或者微信版本过低。", "There is no WeChat or the version is too " +
"low."), 0).show();
c.d(o.a("未安装微信或者微信版本过低。", "There is no WeChat or the version is too low."));
}
示例5: login
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
private void login() {
Platform platform = ShareSDK.getPlatform(QQ.NAME);
if (platform.isAuthValid()) {
showUser(platform);
return;
}
platform.setPlatformActionListener(this);
platform.SSOSetting(false);
platform.showUser(null);
platform.authorize();
}
示例6: thirdSinaLogin
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
/**
* 新浪微博授权、获取用户信息页面
*/
private void thirdSinaLogin() {
//初始化新浪平台
Platform pf = ShareSDK.getPlatform(this, SinaWeibo.NAME);
pf.SSOSetting(true);
//设置监听
pf.setPlatformActionListener((PlatformActionListener) LoginSuccessActivity.this);
//获取登陆用户的信息,如果没有授权,会先授权,然后获取用户信息
pf.authorize();
}
示例7: shareImageToWechat
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
public static void shareImageToWechat(String path, boolean isBitmap) {
Platform.ShareParams shareParams = new Platform.ShareParams();
shareParams.setShareType(isBitmap ? Platform.SHARE_IMAGE : Platform.SHARE_EMOJI);
shareParams.setImagePath(path);
Platform platform = ShareSDK.getPlatform(Wechat.NAME);
platform.share(shareParams);
}
示例8: shareImageToQQ
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
public static void shareImageToQQ(String path, boolean isBitmap) {
Platform.ShareParams shareParams = new Platform.ShareParams();
shareParams.setShareType(isBitmap ? Platform.SHARE_IMAGE : Platform.SHARE_EMOJI);
shareParams.setImagePath(path);
Platform platform = ShareSDK.getPlatform(QQ.NAME);
platform.share(shareParams);
}
示例9: unauthorize
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
public static void unauthorize(Context context, String platformName) {
ensureInit(context);
Platform platform = ShareSDK.getPlatform(context, platformName);
if (platform.isValid()) platform.removeAccount();
}
示例10: getPlatform
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
public static Platform getPlatform(Context context, String platformName) {
ensureInit(context);
return ShareSDK.getPlatform(context, platformName);
}
示例11: authorize
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
/**
* 授权
* @param context
* @param platformName e.g: {@link SinaWeibo#NAME}
* @param paListener 监听,会在UI线程中回调<br/>
* 文档说:这个操作回调并不实际带回什么数据,只是通过回调告知外部成功或者失败
* (<a href="http://wiki.mob.com/Android_授权/取消授权">Android_授权</a>),<br/>
* 文档又说:PlatformActionListener是ShareSDK统一的操作回调。它有三个方法:onComplete、onError和onCancel。分别表示:成功、失败和取消。
* 一般来说,“取消”的事件很少出现,但是授权的时候会有;错误的时候,可以通过对其Throwable参数t执行“t.printStackTrace()”可以得到错误的堆栈。
* 这个堆栈十分重要,如果您向ShareSDK的客服提交bug,请带上这个堆栈,以便他们查询异常。
* 成功的时候,会将操作的结果通过其HashMap<String, Object>参数res进行返回,返回时的res已经解析,可以根据不同平台的api文档,从res中得到返回体的数据。
* 注意这三个回调中的action参数可参见{@link Platform#ACTION_AUTHORIZING}等。
* <pre>
* new PlatformActionListener() {
* public void onError(Platform platform, int action, Throwable e) {}
* public void onComplete(Platform platform, int action, HashMap<String, Object> res) {}
* public void onCancel(Platform platform, int action) {}
* }
* </pre>
*/
public static void authorize(Context context, String platformName, PlatformActionListener paListener) {
ensureInit(context);
Platform platform = ShareSDK.getPlatform(context, platformName);
platform.setPlatformActionListener(getUiThreadActionListener(paListener));
/* true表示不使用SSO方式授权。注意与assets/ShareSDK.xml配置中的ShareByAppClient相区别,两者试用对象不同。
* ShareByAppClient标识是否使用客户端分享,默认是false。只有新浪微博设置为false才能使用一键静默分享,
* 其他平台反正都要弹框,那不如弹客户端的框美观些。
*/
platform.SSOSetting(false);
platform.authorize();
//自定义授权,可能需要更多的权限和调用更多的接口
//platform.authorize(String[]);
}
示例12: isAuthorized
import cn.sharesdk.framework.ShareSDK; //导入方法依赖的package包/类
/**
* 判断某平台是否已经授权(在ShareSDK中,判断此平台是否授权的方法是isValid,而取消授权的方法是removeAccount)。
* @param context
* @param platformName e.g: {@link QZone#NAME}
* @return
*/
public static boolean isAuthorized(Context context, String platformName) {
ensureInit(context);
Platform platform = ShareSDK.getPlatform(context, platformName);
return platform.isValid();
}