用shareToQQ函数分享图文消息,在qq 4.1.1 for android版本下打开联系人列表数秒后会闪退!
在更高版本的V4.5.2.1,V4.2.1下则没有这个问题(证明各种设置没问题),各位确认下是否如此????
代码:
package com.example.share.entry; import org.json.JSONObject; import com.tencent.tauth.Constants;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.Tencent;
import com.tencent.tauth.UiError; import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button; public class MainActivity extends Activity { // QQ互联相关变量(分享至好友、qq空间)
public static Tencent mTencent;
private Button qzoneBtn; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); final Context applicationContext = this.getApplicationContext(); qzoneBtn = (Button) findViewById(R.id.btn_shareToqq);
qzoneBtn.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View v) {
mTencent = Tencent.createInstance("100575179",
applicationContext);
// qq互联,sdk.V2.0.1
final Bundle params = new Bundle();
params.putString(Constants.PARAM_TARGET_URL, "http://bolo.im");
params.putString(Constants.PARAM_TITLE, "bolo分享测试");
params.putString(Constants.PARAM_IMAGE_URL,
"http://img37.dangdang.com/96/26/20444487-1_b.jpg");
params.putString(Constants.PARAM_APP_SOURCE, "bolo"
+ "100575179");
params.putString(Constants.PARAM_APPNAME, "bolo");
mTencent.shareToQQ(MainActivity.this, params,
new BaseUiListener());
}
}); } //接收qzone客户端反馈回本应用的消息(分享成功,失败,取消)
private class BaseUiListener implements IUiListener { @Override
public void onComplete(JSONObject response) {
doComplete(response);
} protected void doComplete(JSONObject values) { } @Override
public void onError(UiError e) {
showResult("onError:", "code:" + e.errorCode + ", msg:"
+ e.errorMessage + ", detail:" + e.errorDetail);
} @Override
public void onCancel() {
showResult("onCancel", "");
}
} private void showResult(final String base, final String msg) { } @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.share.entry"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.share.entry.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <!-- 辅助Activity 加上方向 防止横竖屏切换listener 丢失-->
<activity android:name="com.tencent.connect.common.AssistActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:screenOrientation="portrait" />
<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="tencent100575179" />
</intent-filter>
</activity>
</application> </manifest>
是否对呢?