问题描述
- 游戏接完支付,登录第三方sdk之后报空指针异常但是找不到错误
-
Caused by: java.lang.NullPointerExceptionat com.weedong.gamesdk.utils.PreferencesUtils.getSharedPreferences(PreferencesUtils.java:23)
at com.weedong.gamesdk.utils.PreferencesUtils.getAppId(PreferencesUtils.java:83)
at com.weedong.gamesdk.base.WdSDKControl.getGameInfo(WdSDKControl.java:545)
at com.weedong.gamesdk.base.WdSDKControl.login(WdSDKControl.java:92)
at com.weedong.gamesdk.base.WdGameSDK.login(WdGameSDK.java:43)
at com.tongbulv.sdk.channels.channelmeitu.ChannelMeitu.meiTuLogin(ChannelMeitu.java:148)
at com.tongbulv.sdk.channels.channelmeitu.ChannelMeitu.login(ChannelMeitu.java:65)
at com.tongbulv.tsdk.TSDKUserCenter.login(TSDKUserCenter.java:188)
at com.zxlf.zwhx.MainActivity$6.run(MainActivity.java:776)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5333)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:711)
at dalvik.system.NativeStart.main(Native Method)
上面是代码
但是我的context。和WdGameSDK的实例都打印了都不是空代码如下
private void meiTuLogin(final Context context) {
// TODO Auto-generated method stub
Toast.makeText(context, WdGameSDK.getInstance().toString(), Toast.LENGTH_LONG).show();
Log.e("meiTuLogin", WdGameSDK.getInstance().toString());WdLoginListener wdLoginListener=new WdLoginListener() { @Override public void onCallBack(int arg0, UserInfo arg1) { // TODO Auto-generated method stub } }; Toast.makeText(context, "WdLoginListener"+wdLoginListener.toString(), Toast.LENGTH_LONG).show(); Log.e("WdLoginListener", wdLoginListener.toString()); WdGameSDK.getInstance().login((Activity) context, new WdLoginListener() { @Override public void onCallBack(int paramInt, UserInfo paramInfo) { if (paramInt == WdResultCode.LOGIN_SUCCESS) { String uid=paramInfo.getUid(); String access_token=paramInfo.getSessionid(); bindUser(context,uid,access_token); } else if (paramInt == WdResultCode.LOGIN_CANCEL) { loginFailCallback("登录取消"); } else { loginFailCallback("登录失败"); } } }); } @Override public void login(Context context) { Toast.makeText(context, "login"+context, Toast.LENGTH_LONG).show(); Log.e("login", context.toString()); meiTuLogin(context); }