WebView Activity在第一次启动时崩溃应用程序

时间:2014-10-09 19:22:46

标签: android

我正在使用WebView Activity从重定向网址获取access_token,然后在选择access_token时使用onBackPressed()完成WebView活动。问题是,在MainActivity成功从WebViewActivity接收access_token后,应用程序在大约5秒内崩溃。如果我再次启动我的应用程序(不破坏它),则不会出现问题。

private void startWebView(String url) {

    webView = (WebView) findViewById(R.id.webview);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            Log.d(TAG, url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {

            // get url
            String currentUrl = view.getUrl();
            Log.i(TAG, "current Url is: " + currentUrl);

            // if the redirect url returns access_token, pick access_token
            if (currentUrl.contains("http://google.com/#access_token=")) {
                String[] r = url.split("#");
                String[] tokens = r[1].split("&");
                String accessToken = tokens[0].replace("access_token=", "");

                Log.i(TAG, "! " + accessToken);
                if (accessToken != null) {
                    resultAccessToken = accessToken;
                    Intent intent = new Intent().putExtra("access_token", accessToken);
                    setResult(RESULT_OK, intent);

                    webView.clearHistory();
                    onBackPressed();
                }
            }
        }
    });

    webView.loadUrl(url);
}

logcat的:

libcore.io.ErrnoException: read failed: EAGAIN (Try again)
            at libcore.io.Posix.readBytes(Native Method)
            at libcore.io.Posix.read(Posix.java:128)
            at libcore.io.BlockGuardOs.read(BlockGuardOs.java:149)
            at com.android.server.am.NativeCrashListener.consumeNativeCrashData(NativeCrashListener.java:240)
            at com.android.server.am.NativeCrashListener.run(NativeCrashListener.java:138)
10-09 19:04:52.350    4759-4759/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
10-09 19:04:52.350    4759-4759/? E/android.os.Debug﹕ failed to load memtrack module: -2
10-09 19:04:54.726    4781-4781/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
10-09 19:04:54.730    4781-4781/? E/android.os.Debug﹕ failed to load memtrack module: -2
10-09 19:04:56.306    4791-4791/com.example.android_WebViewApp3 E/AudioManagerAndroid﹕ BLUETOOTH permission is missing!
10-09 19:04:56.786    4791-4791/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
10-09 19:04:56.786    4791-4791/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
10-09 19:04:56.810    4791-4791/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
10-09 19:04:56.810    4791-4791/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
10-09 19:04:57.702    4791-4791/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:04:58.266    4791-4791/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:04:58.382    4791-4791/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:04:58.454    4791-4791/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:04:58.538    4791-4791/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:04:58.626    4791-4791/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:04:58.670    4791-4791/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:04:59.902    4791-4791/com.example.android_WebViewApp3 E/libEGL﹕ call to OpenGL ES API with no current context (logged once per thread)
10-09 19:04:59.938    4791-4791/com.example.android_WebViewApp3 A/libc﹕ Fatal signal 6 (SIGABRT) at 0x000012b7 (code=-6), thread 4791 (oid_WebViewApp3)
10-09 19:05:02.198      581-610/system_process E/InputDispatcher﹕ channel '529580ac com.example.android_WebViewApp3/com.example.android_WebViewApp3.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-09 19:05:02.198      581-610/system_process E/InputDispatcher﹕ channel '5295a4d8 Toast (server)' ~ Channel is unrecoverably broken and will be disposed!
10-09 19:05:08.342    4850-4850/com.example.android_WebViewApp3 E/AudioManagerAndroid﹕ BLUETOOTH permission is missing!
10-09 19:05:08.814    4850-4850/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
10-09 19:05:08.818    4850-4850/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
10-09 19:05:08.834    4850-4850/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
10-09 19:05:08.834    4850-4850/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
10-09 19:05:09.734    4850-4850/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:05:10.342    4850-4850/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:05:10.442    4850-4850/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:05:10.590    4850-4850/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:05:10.670    4850-4850/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:05:10.726    4850-4850/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:05:10.774    4850-4850/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:05:16.418    4850-4850/com.example.android_WebViewApp3 E/libEGL﹕ call to OpenGL ES API with no current context (logged once per thread)
10-09 19:05:55.174    4905-4905/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
10-09 19:05:55.174    4905-4905/? E/android.os.Debug﹕ failed to load memtrack module: -2
10-09 19:05:55.530      581-610/system_process E/InputDispatcher﹕ channel '529c8090 com.example.android_WebViewApp3/com.example.android_WebViewApp3.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-09 19:05:58.774    4927-4927/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
10-09 19:05:58.778    4927-4927/? E/android.os.Debug﹕ failed to load memtrack module: -2
10-09 19:05:59.666      801-801/com.android.launcher E/EGL_genymotion﹕ egl: current context mark for deletion
10-09 19:06:00.250    4937-4937/com.example.android_WebViewApp3 E/AudioManagerAndroid﹕ BLUETOOTH permission is missing!
10-09 19:06:00.758    4937-4937/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
10-09 19:06:00.762    4937-4937/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
10-09 19:06:00.782    4937-4937/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
10-09 19:06:00.786    4937-4937/com.example.android_WebViewApp3 E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 8192
10-09 19:06:02.138    4937-4937/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:06:02.742    4937-4937/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:06:02.826    4937-4937/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:06:02.886    4937-4937/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:06:02.938    4937-4937/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:06:02.990    4937-4937/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:06:03.054    4937-4937/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:06:03.134    4937-4937/com.example.android_WebViewApp3 E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,73)
10-09 19:06:05.466    4937-4937/com.example.android_WebViewApp3 E/libEGL﹕ call to OpenGL ES API with no current context (logged once per thread)

0 个答案:

没有答案