|
安卓已经实现了点击后跳转到QQ登录界面,但是无法获得返回的json信息。
CallbackContext都不会执行到,有人有研究过吗?
腾讯sdk:Android_SDK_V2.9.3
phonegap:phonegap-2.9.0
public class QqLogin extends cordovaPlugin{
private static Tencent mTencent;
private Context context;
private Activity activity;
private CallbackContext mCallbackContext = null;
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
activity=this.cordova.getActivity();
context = this.cordova.getActivity().getApplicationContext();
mTencent = Tencent.createInstance("我的key", context);
}
public boolean execute(String action, JSONArray args,CallbackContext callbackContext) throws JSONException
{
mCallbackContext=callbackContext;
if (action.equals("login")) {
String message = args.getString(0);
this.login(message, callbackContext);
return true;
}
return false;
}
private void login(String message, CallbackContext callbackContext) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
mTencent.login(activity, "all", prizeQueryUnexchangeListener);
}
});
}
private IUiListener prizeQueryUnexchangeListener = new IUiListener() {
@Override
public void onError(UiError e) {
mCallbackContext.error(0);
}
@Override
public void onCancel() {
mCallbackContext.error(0);
}
@Override
public void onComplete(Object response) {
System.out.println("onComplete"+response.toString());
mCallbackContext.success("123");
}
};
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
mTencent.onActivityResult(requestCode, resultCode, intent);
super.onActivityResult(requestCode, resultCode, intent);
// 传递返回值 给js方法
mCallbackContext.success(1);
}
}
后台日志:
09-01 16:52:25.208: E/openSDK_LOG.UIListenerManager(9745): setListener action is null! rquestCode=11101
09-01 16:52:25.218: E/openSDK_LOG.APNUtil(9745): getApn has exception: No permission to write APN settings: Neither user 10324 nor current process has android.permission.WRITE_APN_SETTINGS.
报了这两条错,不懂为什么
|
|