本文整理匯總了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();
}