android方法被调用两次,android webview函数onPagefinished被调用两次

我的

android webview函数onPageFinished被调用两次.我不知道为什么,但它在

Android 2.2上运行良好,但当我升级到4时它不起作用.代码如下

@Override

public void onPageFinished(WebView view, String url) {

if (url.startsWith(MobileConstants.PUSHPIN_CALLBACK_URL)) {

if (url.indexOf("code=")!=-1) {

String code = url.substring(url.indexOf("code=")+5);

Log.i ("code", code);

if (code != null && !code.equals("") ){

view.setVisibility(View.GONE);

Token accessToken = service.getAccessToken(null, new Verifier(code));

Log.i("access_token",accessToken.getToken());

SharedPreferences settings = getSharedPreferences("access_token" , 0);

SharedPreferences.Editor editor = settings.edit();

if(accessToken.getToken() != null)

editor.putString("access_token", accessToken.getToken() );

Intent map3 = new Intent(OAuthAccessTokenActivity.this, Dashboard.class);

map3.putExtra("access_token", accessToken.getToken());

startActivity(map3);

}

} else if (url.indexOf("error=")!=-1) {

view.setVisibility(View.INVISIBLE);

}

}

System.out.println("onPageFinished : " + url);

}

日志

07-22 14:29:50.523: E/AndroidRuntime(1186): FATAL EXCEPTION: main

07-22 14:29:50.523: E/AndroidRuntime(1186): java.lang.NullPointerException

07-22 14:29:50.523: E/AndroidRuntime(1186): at com.facebook.android.OAuthAccessTokenActivity$1.onPageFinished(OAuthAccessTokenActivity.java:83)

07-22 14:29:50.523: E/AndroidRuntime(1186): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:327)

07-22 14:29:50.523: E/AndroidRuntime(1186): at android.os.Handler.dispatchMessage(Handler.java:99)

07-22 14:29:50.523: E/AndroidRuntime(1186): at android.os.Looper.loop(Looper.java:137)

07-22 14:29:50.523: E/AndroidRuntime(1186): at android.app.ActivityThread.main(ActivityThread.java:4745)

07-22 14:29:50.523: E/AndroidRuntime(1186): at java.lang.reflect.Method.invokeNative(Native Method)

07-22 14:29:50.523: E/AndroidRuntime(1186): at java.lang.reflect.Method.invoke(Method.java:511)

07-22 14:29:50.523: E/AndroidRuntime(1186): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)

07-22 14:29:50.523: E/AndroidRuntime(1186): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

07-22 14:29:50.523: E/AndroidRuntime(1186): at dalvik.system.NativeStart.main(Native Method)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值