<!-- QZone分享必須加上以下兩個activity -->
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name="com.tencent.tauth.AuthActivity"
android:launchMode="singleTask"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tencent222222" /> <!--Appid:222222--
>
<!-- 100380359 100381104 222222 -->
</intent-filter>
</activity>
oncreate中
//QQ
mTencent = Tencent.createInstance(Constant.QQKJ_APPID, this);
/**
* qq空間分享
* @param v
*/
public void toShareQQKJ(){
final Bundle params = new Bundle();
params.putInt(QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzoneShare.SHARE_TO_QZONE_TYPE_IMAGE_TEXT);//類型
params.putString(QzoneShare.SHARE_TO_QQ_TITLE, "霸氣的小明");//標題
params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, "霸氣的呵呵小明 ");//概要
params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, " http://www.beehood.com");
//以下這個必須加上 不然無法調動 qq空間
ArrayList<String> imageUrls = new ArrayList<String>();
imageUrls.add(" http://www.beehood.com/uploads/allimg/150310/2-150310142133.jpg");
params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, imageUrls);
doShareToQzone(params);
}
/**
* 用異步方式啟動分享
* @param params
*/
private void doShareToQzone(final Bundle params) {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mTencent.shareToQzone(SettingActivity.this, params, qZoneShareListener);
}
}).start();
}
/**
* 分享監聽
*/
IUiListener qZoneShareListener = new IUiListener() {
@Override
public void onCancel() {
// Toast.makeText(SettingActivity.this, "取消", 0).show();
Log.i("QZone", "取消分享");
}
@Override
public void onError(UiError e) {
Log.i("QZone", "出錯:"+e.errorMessage);
// TODO Auto-generated method stub
// Toast.makeText(SettingActivity.this, "onError: " + e.errorMessage, 0).show();
// Util.toastMessage(QZoneShareActivity.this, "onError: " + e.errorMessage, "e");
}
@Override
public void onComplete(Object response) {
Log.i("QZone", "完畢分享");
// TODO Auto-generated method stub
// Toast.makeText(SettingActivity.this, "onComplete: " + response.toString(), 0).show();
// Util.toastMessage(QZoneShareActivity.this, "onComplete: " + response.toString());
}
* qq空間分享
* @param v
*/
public void toShareQQKJ(){
final Bundle params = new Bundle();
params.putInt(QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzoneShare.SHARE_TO_QZONE_TYPE_IMAGE_TEXT);//類型
params.putString(QzoneShare.SHARE_TO_QQ_TITLE, "霸氣的小明");//標題
params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, "霸氣的呵呵小明 ");//概要
params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, " http://www.beehood.com");
//以下這個必須加上 不然無法調動 qq空間
ArrayList<String> imageUrls = new ArrayList<String>();
imageUrls.add(" http://www.beehood.com/uploads/allimg/150310/2-150310142133.jpg");
params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, imageUrls);
doShareToQzone(params);
}
/**
* 用異步方式啟動分享
* @param params
*/
private void doShareToQzone(final Bundle params) {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mTencent.shareToQzone(SettingActivity.this, params, qZoneShareListener);
}
}).start();
}
/**
* 分享監聽
*/
IUiListener qZoneShareListener = new IUiListener() {
@Override
public void onCancel() {
// Toast.makeText(SettingActivity.this, "取消", 0).show();
Log.i("QZone", "取消分享");
}
@Override
public void onError(UiError e) {
Log.i("QZone", "出錯:"+e.errorMessage);
// TODO Auto-generated method stub
// Toast.makeText(SettingActivity.this, "onError: " + e.errorMessage, 0).show();
// Util.toastMessage(QZoneShareActivity.this, "onError: " + e.errorMessage, "e");
}
@Override
public void onComplete(Object response) {
Log.i("QZone", "完畢分享");
// TODO Auto-generated method stub
// Toast.makeText(SettingActivity.this, "onComplete: " + response.toString(), 0).show();
// Util.toastMessage(QZoneShareActivity.this, "onComplete: " + response.toString());
}
};