错误 java.lang.NullPointerException 仅在 Android 4.2 应用程序崩溃仅在 android 4.2 中,对于 android 4.0 运行良好在带有模拟器 4.2 的 Eclipse 中不是 logcat 中的错误,但在 google play 开发人员中是的,对不起我的英语,谢谢帮助我
java.lang.NullPointerException
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2565)
at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2820)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5162)
at android.view.ViewRootImpl.die(ViewRootImpl.java:5145)
at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:359)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:309)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3535)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3717)
at android.app.ActivityThread.access$700(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
活动
public class directo extends Activity
{
private LinearLayout ll;
private WebView webview2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.directo);
ll = (LinearLayout) findViewById(R.id.container1);
showVideo1();
}
@Override
protected void onPause() {
super.onPause(); //To change body of overridden methods use File | Settings | File Templates.
webview2.onPause();
}
@Override
protected void onResume() {
super.onResume(); //To change body of overridden methods use File | Settings | File Templates.
webview2.onResume();
}
@Override
protected void onDestroy() {
webview2.onPause();
super.onDestroy();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
public void showVideo1(){
webview2 = new WebView(this);
webview2.getSettings().setJavaScriptEnabled(true);
webview2.getSettings().setLoadWithOverviewMode(true);
webview2.getSettings().setUseWideViewPort(true);
webview2.setWebViewClient(new mWebViewClient());
webview2.getSettings().setPluginsEnabled(true);
webview2.setWebChromeClient( new FullscreenableChromeClient(this));
webview2.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.36 (KHTML, like Gecko) Chrome/13.0.766.0 Safari/534.36");
webview2.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
1f));
String js = "<iframe type=\"text/html\" width=\"100%\" height=\"100%\" src=\"http://veetle.com/index.php/mobile/channel/4d09f6339bb0b\" frameborder=\"0\">\n" +
"</iframe>\n" +
"";
webview2.loadDataWithBaseURL("fake://fake.com", js,
"text/html", "UTF-8", null);
ll.addView(webview2, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
private class mWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent msg) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
return true;
}
return false;
}
public void recargar(View view) {
Intent intent = new Intent(this, directo.class);
//intent.putExtra("someData", "Here is some data");
startActivityForResult(intent, 1);
}
public void volver(View view) {
Intent intent = new Intent(this, inicio1.class);
//intent.putExtra("someData", "Here is some data");
startActivityForResult(intent, 1);
}
}
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true"
android:orientation="vertical" >
<Button
android:id="@+id/btn_set_date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="volver"
android:text="@string/volver" />
<Button
android:id="@+id/btn_set_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="recargar"
android:text="@string/recargar" />
</LinearLayout>
日志猫
08-15 20:02:27.899: W/ActivityThread(1062): Application com.futbolespanoltv.android is waiting for the debugger on port 8100...
08-15 20:02:27.968: I/System.out(1062): Sending WAIT chunk
08-15 20:02:27.978: I/dalvikvm(1062): Debugger is active
08-15 20:02:28.168: I/System.out(1062): Debugger has connected
08-15 20:02:28.168: I/System.out(1062): waiting for debugger to settle...
08-15 20:02:28.368: I/System.out(1062): waiting for debugger to settle...
08-15 20:02:28.568: I/System.out(1062): waiting for debugger to settle...
08-15 20:02:28.778: I/System.out(1062): waiting for debugger to settle...
08-15 20:02:28.978: I/System.out(1062): waiting for debugger to settle...
08-15 20:02:29.178: I/System.out(1062): waiting for debugger to settle...
08-15 20:02:29.378: I/System.out(1062): waiting for debugger to settle...
08-15 20:02:29.640: I/System.out(1062): debugger has settled (1303)
08-15 20:02:31.428: D/dalvikvm(1062): GC_FOR_ALLOC freed 204K, 12% free 2490K/2816K, paused 130ms, total 142ms
08-15 20:02:31.458: I/dalvikvm-heap(1062): Grow heap (frag case) to 4.588MB for 2141456-byte allocation
08-15 20:02:31.608: D/dalvikvm(1062): GC_FOR_ALLOC freed 2K, 7% free 4579K/4908K, paused 148ms, total 148ms
08-15 20:02:31.708: D/dalvikvm(1062): GC_CONCURRENT freed 9K, 7% free 4581K/4908K, paused 17ms+6ms, total 100ms
08-15 20:02:32.058: D/dalvikvm(1062): GC_FOR_ALLOC freed 11K, 7% free 4584K/4908K, paused 30ms, total 30ms
08-15 20:02:32.118: I/dalvikvm-heap(1062): Grow heap (frag case) to 9.187MB for 4818256-byte allocation
08-15 20:02:32.308: D/dalvikvm(1062): GC_CONCURRENT freed 0K, 4% free 9289K/9616K, paused 95ms+16ms, total 190ms
08-15 20:02:32.308: D/dalvikvm(1062): WAIT_FOR_CONCURRENT_GC blocked 96ms
08-15 20:02:32.838: I/Choreographer(1062): Skipped 39 frames! The application may be doing too much work on its main thread.
08-15 20:02:33.089: D/gralloc_goldfish(1062): Emulator without GPU emulation detected.
08-15 20:02:39.738: I/Choreographer(1062): Skipped 48 frames! The application may be doing too much work on its main thread.
08-15 20:02:41.749: I/Choreographer(1062): Skipped 414 frames! The application may be doing too much work on its main thread.
08-15 20:02:42.149: I/Choreographer(1062): Skipped 66 frames! The application may be doing too much work on its main thread.
08-15 20:02:42.779: I/Choreographer(1062): Skipped 34 frames! The application may be doing too much work on its main thread.
08-15 20:02:43.259: I/Choreographer(1062): Skipped 32 frames! The application may be doing too much work on its main thread.
08-15 20:02:47.868: I/Choreographer(1062): Skipped 35 frames! The application may be doing too much work on its main thread.
08-15 20:02:54.378: I/Choreographer(1062): Skipped 35 frames! The application may be doing too much work on its main thread.
08-15 20:02:54.438: D/TilesManager(1062): Starting TG #0, 0x2a509088
08-15 20:02:55.278: I/Choreographer(1062): Skipped 56 frames! The application may be doing too much work on its main thread.
08-15 20:02:59.739: I/Choreographer(1062): Skipped 42 frames! The application may be doing too much work on its main thread.
08-15 20:03:01.718: D/dalvikvm(1062): GC_FOR_ALLOC freed 2426K, 24% free 8492K/11040K, paused 103ms, total 128ms
08-15 20:03:02.139: I/Choreographer(1062): Skipped 398 frames! The application may be doing too much work on its main thread.
08-15 20:03:02.929: I/Choreographer(1062): Skipped 121 frames! The application may be doing too much work on its main thread.
08-15 20:03:03.569: I/Choreographer(1062): Skipped 53 frames! The application may be doing too much work on its main thread.
08-15 20:03:04.989: I/Choreographer(1062): Skipped 33 frames! The application may be doing too much work on its main thread.
08-15 20:03:07.449: E/Web Console(1062): Uncaught Url::appStore app does not exist on platform at http://veetle.com/minified/ff46d3264790eff826475edd292e3fc8_minified.js:194
08-15 20:03:07.768: E/Web Console(1062): Url::appChannel app does not exist on platform at http://veetle.com/minified/ff46d3264790eff826475edd292e3fc8_minified.js:343
08-15 20:03:08.268: D/libEGL(1062): Emulator without GPU support detected. Fallback to software renderer.
08-15 20:03:08.278: D/libEGL(1062): loaded /system/lib/egl/libGLES_android.so
08-15 20:03:08.308: E/Web Console(1062): Unsafe JavaScript attempt to access frame with URL fake://fake.com from frame with URL http://veetle.com/index.php/mobile/channel/5208af0563c2d. Domains, protocols and ports must match.
08-15 20:03:08.308: E/Web Console(1062): at null:1
08-15 20:03:08.658: I/OMXClient(1062): Using client-side OMX mux.
08-15 20:03:08.718: E/Web Console(1062): Unsafe JavaScript attempt to access frame with URL fake://fake.com from frame with URL http://veetle.com/index.php/mobile/channel/5208af0563c2d. Domains, protocols and ports must match.
08-15 20:03:08.718: E/Web Console(1062): at null:1