QQ登入(4)QQ分享-内容转载
///////////////////QQ分享///////////// public void myclick3(View v){ //shareType : SHARE_TO_QQ_TYPE_IMAGE,SHARE_TO_QQ_TYPE_AUDIO,SHARE_TO_QQ_TYPE_DEFAULT int shareType = QQShare.SHARE_TO_QQ_TYPE_DEFAULT; //mExtarFlag:0x00,0x00|= QQShare.SHARE_TO_QQ_FLAG_QZONE_AUTO_OPEN,0x00|= QQShare.SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE //无弹窗 ,显示分享到QQ空间 int mExtarFlag = 0x00; //有弹窗 ,显示分享到QQ空间 //mExtarFlag |= QQShare.SHARE_TO_QQ_FLAG_QZONE_AUTO_OPEN; //无弹窗 ,无显示分享到QQ空间 //mExtarFlag |= QQShare.SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE; final Bundle params = new Bundle(); if (shareType != QQShare.SHARE_TO_QQ_TYPE_IMAGE) { params.putString(QQShare.SHARE_TO_QQ_TITLE, "标题"); params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, "http://WWW.BAIDU.COM"); params.putString(QQShare.SHARE_TO_QQ_SUMMARY, "内容"); } if (shareType == QQShare.SHARE_TO_QQ_TYPE_IMAGE) { params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, "http://img3.douban.com/lpic/s3635685.jpg"); } else { params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL,"http://img3.douban.com/lpic/s3635685.jpg"); } params.putString(shareType == QQShare.SHARE_TO_QQ_TYPE_IMAGE ? QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL : QQShare.SHARE_TO_QQ_IMAGE_URL, "http://img3.douban.com/lpic/s3635685.jpg"); params.putString(QQShare.SHARE_TO_QQ_APP_NAME, "应用名称"); params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, shareType); params.putInt(QQShare.SHARE_TO_QQ_EXT_INT, mExtarFlag); if (shareType == QQShare.SHARE_TO_QQ_TYPE_AUDIO) { //音乐链接地址 params.putString(QQShare.SHARE_TO_QQ_AUDIO_URL, "http://mr3.douban.com/201307291529/13a106d9b49a9a8446fd3c18f77dc395/view/song/small/p8508.mp3"); } if ((mExtarFlag & QQShare.SHARE_TO_QQ_FLAG_QZONE_AUTO_OPEN) != 0) { Toast.makeText(getApplicationContext(), "在好友选择列表会自动打开分享到qzone的弹窗~~~", 0).show(); } else if ((mExtarFlag & QQShare.SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE) != 0) { Toast.makeText(getApplicationContext(), "在好友选择列表隐藏了qzone分享选项", 0).show(); } doShareToQQ(params); } /** * 用异步方式启动分享 * @param params */ private void doShareToQQ(final Bundle params) { final Activity activity = MyQQloginShareActivity.this; String mAppid2="222222"; QQAuth mQQAuth = QQAuth.createInstance(mAppid2, this); final QQShare mQQShare = new QQShare(this,mQQAuth.getQQToken()); new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub mQQShare.shareToQQ(activity, params, new IUiListener() { @Override public void onCancel() { Toast.makeText(getApplicationContext(), "分享取消", 0).show(); } @Override public void onComplete(Object response) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "分享成功", 0).show(); } @Override public void onError(UiError e) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "分享出错", 0).show(); } }); } }).start(); }
源码:链接: http://pan.baidu.com/s/1qWwJQ24
posted on 2014-04-20 02:19 clarenceV1 阅读(1051) 评论(0) 编辑 收藏 举报