本文整理汇总了Java中com.sina.weibo.sdk.api.share.IWeiboShareAPI类的典型用法代码示例。如果您正苦于以下问题:Java IWeiboShareAPI类的具体用法?Java IWeiboShareAPI怎么用?Java IWeiboShareAPI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IWeiboShareAPI类属于com.sina.weibo.sdk.api.share包,在下文中一共展示了IWeiboShareAPI类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shareToWeibo
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
public static void shareToWeibo(String transaction, Activity activity, String title, String summary, Bitmap img) {
ImageObject imageObject = new ImageObject();
imageObject.imageData = bmpToByteArray(img);
TextObject textObject = new TextObject();
textObject.text = title + "\n" + summary + Constants.SUMMARY;
WeiboMultiMessage message = new WeiboMultiMessage();
message.textObject = textObject;
message.imageObject = imageObject;
SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
request.transaction = transaction;
request.multiMessage = message;
AuthInfo authInfo = new AuthInfo(activity, Constants.WB_APP_ID, Constants.WB_REDIRECT_URL, Constants.WB_SCOPE);
Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(APP_CONTEXT);
String token = "";
if (accessToken != null) {
token = accessToken.getToken();
}
IWeiboShareAPI api = getWbApi();
api.sendRequest(activity, request, authInfo, token, weiboAuthListener);
}
示例2: getInstance
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
public static IWeiboShareAPI getInstance(Context context, String appKey) {
LogUtil.enableLog();
if (null == api) {
api = WeiboShareSDK.createWeiboAPI(context, appKey);
api.registerApp();
}
return api;
}
示例3: shareLocalImage
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
private void shareLocalImage(IWeiboShareAPI api, Share share, Callback callback) {
WeiboMultiMessage msg = new WeiboMultiMessage();
ImageObject img = new ImageObject();
img.setImageObject(share.getThumbBitmap());
msg.imageObject = img;
SendMultiMessageToWeiboRequest multRequest = new SendMultiMessageToWeiboRequest();
multRequest.multiMessage = msg;
//以当前时间戳为唯一识别符
multRequest.transaction = String.valueOf(System.currentTimeMillis());
if (api.sendRequest(activity, multRequest)) {
callback.onSuccess();
} else {
callback.onFailed();
}
}
示例4: getWbApi
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
private synchronized static IWeiboShareAPI getWbApi() {
if (WB_API == null) {
IWeiboShareAPI mWeiboShareAPI = WeiboShareSDK.createWeiboAPI(APP_CONTEXT, Constants.WB_APP_ID);
mWeiboShareAPI.registerApp();
WB_API = mWeiboShareAPI;
}
return WB_API;
}
示例5: onCreate
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sina_activity);
ButterKnife.bind(this);
authInfo = new AuthInfo(SinaActivity.this, SINA_APPID, SINA_REDIRECT_URL, SINA_SCOPE);
ssoHandler = new SsoHandler(SinaActivity.this, authInfo);
IWeiboShareAPI weiboShareAPI = WeiboShareSDK.createWeiboAPI(SinaActivity.this, SINA_APPID);
weiboShareAPI.registerApp();
}
示例6: isInstall
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
@Override
public boolean isInstall(Context context) {
IWeiboShareAPI shareAPI =
WeiboShareSDK.createWeiboAPI(context, ShareManager.CONFIG.getWeiboId());
return shareAPI.isWeiboAppInstalled();
}
示例7: isWeiBoInstalled
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
@Deprecated
public static boolean isWeiBoInstalled(@NonNull Context context) {
IWeiboShareAPI shareAPI =
WeiboShareSDK.createWeiboAPI(context, ShareManager.CONFIG.getWeiboId());
return shareAPI.isWeiboAppInstalled();
}
示例8: getWeiboApi
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
public static IWeiboShareAPI getWeiboApi() {
return sWeiboApi;
}
示例9: shareToXinLangWeibo
import com.sina.weibo.sdk.api.share.IWeiboShareAPI; //导入依赖的package包/类
/**
* 分享到新浪微博
* @param activity 上下文
* @param shareContent 分享内容
*/
static void shareToXinLangWeibo(Activity activity, ShareContent shareContent) {
DebugLog.d(TAG, "shareToXinLangWeibo() shareContent = " + shareContent);
IWeiboShareAPI weiboShareAPI = WeiboShareSDK.createWeiboAPI(activity, MyApp.getApp().d());
weiboShareAPI.registerApp();
if (weiboShareAPI.isWeiboAppSupportAPI()) {
int supportApi = weiboShareAPI.getWeiboAppSupportAPI();
if (supportApi >= 10351 /*ApiUtils.BUILD_INT_VER_2_2*/) {
WeiboMultiMessage weiboMessage = new WeiboMultiMessage();
TextObject textObject = new TextObject();
textObject.text = shareContent.getSummary();
weiboMessage.textObject = textObject;
ImageObject imageObject = new ImageObject();
imageObject.setImageObject(((BitmapDrawable)activity.getResources().getDrawable(R.drawable.ic_logo)).getBitmap());
weiboMessage.imageObject = imageObject;
WebpageObject mediaObject = new WebpageObject();
mediaObject.identify = Utility.generateGUID();
mediaObject.title = shareContent.getTitle();
mediaObject.description = shareContent.getSummary();
// 设置 Bitmap 类型的图片到视频对象里
mediaObject.setThumbImage(((BitmapDrawable)activity.getResources().getDrawable(R.drawable.ic_logo)).getBitmap());
mediaObject.actionUrl = shareContent.getLinkUrl();
mediaObject.defaultText = shareContent.getSummary();
weiboMessage.mediaObject = mediaObject;
// 2. 初始化从第三方到微博的消息请求
SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
// 用transaction唯一标识一个请求
request.transaction = String.valueOf(System.currentTimeMillis());
request.multiMessage = weiboMessage;
// 3. 发送请求消息到微博,唤起微博分享界面
weiboShareAPI.sendRequest(activity, request);
} else {
}
} else {
Toast.makeText(activity, R.string.third_party_weibo_hint, Toast.LENGTH_SHORT).show();
}
}