Android webview crashing? - android

I'm trying to make an app for a website, basically just loads the website. I know how to make it and everything, and I've set up webviews, but I'm not sure what I'm doing wrong.
So basically my main class loads a menu, it has buttons for like home, forums, inbox, etc. That all works fine, but when I hit a button, that calls the webview, and that's when it crashes.
Here's my code for the webview:
public class OpenHome extends Activity{
WebView myWebView;
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
WebView myWebView = (WebView) findViewById(R.id.WebView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl("http://www.se7ensins.com");
}
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the BACK key and if there's history
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
myWebView.goBack();
return true;
}
// If it wasn't the BACK key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}
I have all the imports and stuff, but when I run the webview and try to load the page, it just unexpectedly closes the app, also I enabled internet permissions in the android manifest.
Here's the Logcat:
09-03 06:08:03.287: DEBUG/AndroidRuntime(563): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-03 06:08:03.287: DEBUG/AndroidRuntime(563): CheckJNI is ON
09-03 06:08:04.177: DEBUG/AndroidRuntime(563): Calling main entry com.android.commands.pm.Pm
09-03 06:08:04.217: DEBUG/AndroidRuntime(563): Shutting down VM
09-03 06:08:04.237: DEBUG/dalvikvm(563): GC_CONCURRENT freed 100K, 84% free 339K/2048K, paused 0ms+0ms
09-03 06:08:04.237: INFO/AndroidRuntime(563): NOTE: attach of thread 'Binder Thread #3' failed
09-03 06:08:04.247: DEBUG/jdwp(563): Got wake-up signal, bailing out of select
09-03 06:08:04.247: DEBUG/dalvikvm(563): Debugger has detached; object registry had 1 entries
09-03 06:08:04.887: DEBUG/AndroidRuntime(573): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-03 06:08:04.887: DEBUG/AndroidRuntime(573): CheckJNI is ON
09-03 06:08:05.886: DEBUG/AndroidRuntime(573): Calling main entry com.android.commands.am.Am
09-03 06:08:05.936: INFO/ActivityManager(79): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.clepto.sinnergy/.SinnergyActivity } from pid 573
09-03 06:08:05.969: WARN/WindowManager(79): Failure taking screenshot for (230x143) to layer 21005
09-03 06:08:05.996: INFO/ActivityManager(79): Start proc com.clepto.sinnergy for activity com.clepto.sinnergy/.SinnergyActivity: pid=581 uid=10036 gids={3003}
09-03 06:08:06.057: DEBUG/AndroidRuntime(573): Shutting down VM
09-03 06:08:06.086: INFO/AndroidRuntime(573): NOTE: attach of thread 'Binder Thread #3' failed
09-03 06:08:06.186: DEBUG/dalvikvm(573): GC_CONCURRENT freed 101K, 83% free 364K/2048K, paused 1ms+1ms
09-03 06:08:06.186: DEBUG/jdwp(573): Got wake-up signal, bailing out of select
09-03 06:08:06.186: DEBUG/dalvikvm(573): Debugger has detached; object registry had 1 entries
09-03 06:08:08.057: DEBUG/dalvikvm(581): GC_FOR_ALLOC freed 32K, 3% free 6345K/6531K, paused 71ms
09-03 06:08:08.078: INFO/dalvikvm-heap(581): Grow heap (frag case) to 6.828MB for 614416-byte allocation
09-03 06:08:08.186: DEBUG/dalvikvm(581): GC_FOR_ALLOC freed <1K, 4% free 6945K/7175K, paused 79ms
09-03 06:08:08.356: DEBUG/dalvikvm(581): GC_CONCURRENT freed <1K, 4% free 6945K/7175K, paused 20ms+3ms
09-03 06:08:08.616: DEBUG/dalvikvm(147): GC_EXPLICIT freed 7K, 18% free 14098K/17159K, paused 5ms+376ms
09-03 06:08:08.656: DEBUG/dalvikvm(581): GC_CONCURRENT freed 779K, 12% free 6715K/7559K, paused 5ms+3ms
09-03 06:08:08.676: VERBOSE/TLINE(581): new: android.text.TextLine#4063b850
09-03 06:08:09.216: VERBOSE/TLINE(581): new: android.text.TextLine#4072ad08
09-03 06:08:09.279: INFO/ActivityManager(79): Displayed com.clepto.sinnergy/.SinnergyActivity: +3s288ms
09-03 06:08:10.216: DEBUG/dalvikvm(147): GC_EXPLICIT freed <1K, 18% free 14099K/17159K, paused 229ms+4ms
09-03 06:08:13.236: INFO/ActivityManager(79): Starting: Intent { act=com.clepto.sinnergy.OPENHOME } from pid 581
09-03 06:08:13.247: DEBUG/AndroidRuntime(581): Shutting down VM
09-03 06:08:13.247: WARN/dalvikvm(581): threadid=1: thread exiting with uncaught exception (group=0x40014760)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): FATAL EXCEPTION: main
09-03 06:08:13.256: ERROR/AndroidRuntime(581): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.clepto.sinnergy.OPENHOME }
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1382)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.app.Activity.startActivityForResult(Activity.java:3095)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.app.Activity.startActivity(Activity.java:3201)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at com.clepto.sinnergy.SinnergyActivity$1.onClick(SinnergyActivity.java:34)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.view.View.performClick(View.java:3110)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.view.View$PerformClick.run(View.java:11928)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.os.Handler.handleCallback(Handler.java:587)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.os.Handler.dispatchMessage(Handler.java:92)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.os.Looper.loop(Looper.java:132)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at android.app.ActivityThread.main(ActivityThread.java:4025)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at java.lang.reflect.Method.invokeNative(Native Method)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at java.lang.reflect.Method.invoke(Method.java:491)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
09-03 06:08:13.256: ERROR/AndroidRuntime(581): at dalvik.system.NativeStart.main(Native Method)
09-03 06:08:13.276: WARN/ActivityManager(79): Force finishing activity com.clepto.sinnergy/.SinnergyActivity
09-03 06:08:13.276: WARN/WindowManager(79): Failure taking screenshot for (230x143) to layer 21010
09-03 06:08:13.800: WARN/ActivityManager(79): Activity pause timeout for ActivityRecord{41470780 com.clepto.sinnergy/.SinnergyActivity}
09-03 06:08:16.542: INFO/Process(581): Sending signal. PID: 581 SIG: 9
09-03 06:08:16.566: INFO/ActivityManager(79): Process com.clepto.sinnergy (pid 581) has died.
09-03 06:08:16.566: INFO/WindowManager(79): WIN DEATH: Window{4144bae8 com.clepto.sinnergy/com.clepto.sinnergy.SinnergyActivity paused=false}
09-03 06:08:16.696: WARN/InputManagerService(79): Got RemoteException sending setActive(false) notification to pid 581 uid 10036
09-03 06:08:16.930: INFO/dalvikvm(79): Jit: resizing JitTable from 2048 to 4096
09-03 06:08:22.138: DEBUG/SntpClient(79): request time failed: java.net.SocketException: Address family not supported by protocol
09-03 06:08:24.788: WARN/ActivityManager(79): Activity destroy timeout for ActivityRecord{41470780 com.clepto.sinnergy/.SinnergyActivity}

I think your code is almost perfect..
just need to change one line
write this line
myWebView = (WebView) findViewById(R.id.WebView);
instead of
WebView myWebView = (WebView) findViewById(R.id.WebView);
just remove WebView object bcz you already define in global..
and may be some problem in you webview.xml file ?
check it first.
here is samle code for webview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.webkit.WebView android:id="#+id/WebView"
android:layout_width="fill_parent" android:layout_height="fill_parent">
</android.webkit.WebView>
</LinearLayout>
Update
One thing did you add .OpenHome activity in your menifest.xml file
How to check LogCat
go Window >> Show view >> other >> Android >> LogCat
How to add activity in menifest.xml
open AndroidMenifest.xml from you project directory
and add this line
<activity android:name=".OpenHome"></activity>
how to start new activity
Intent intent = new Intent(your_main_class.this,OpenHome.class);
startActivity(intent);
where your_main_class is your main class name .

This is not because of webview.
FATAL EXCEPTION: main 09-03 06:08:13.256: ERROR/AndroidRuntime(581):
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=com.clepto.sinnergy.OPENHOME }
This error is because of the activity is not defined in manifest.
Verify the package and class name of your activity in manifest carefully.

Related

After changing gst-lib-version app falls down

I'm writing an Android App witch recieves udp videostreem and render it on display.
Before changing version of gstreamer from Congo to 1.4.0 the App stops with this:
09-03 15:38:20.630: D/GStreamer(12874): Surface destroyed
09-03 15:38:20.640: D/GStreamer+Piovra(12874): 0:04:04.929366696 0x521ecd20 jni/Piovra.c:907:gst_native_surface_finalize Releasing Native Window 0x522de008
09-03 15:38:21.020: D/GStreamer+Piovra(12874): 0:04:05.317334029 0x521ecd20 jni/Piovra.c:823:gst_native_finalize Quitting video main loop...
09-03 15:38:21.020: D/GStreamer+Piovra(12874): 0:04:05.317554696 0x521ecd20 jni/Piovra.c:827:gst_native_finalize Waiting for threads to finish...
09-03 15:38:21.020: D/GStreamer+Piovra(12874): 0:04:05.317907696 0x522ec220 jni/Piovra.c:368:video_app_function Exited main loop
09-03 15:38:21.030: D/dalvikvm(12874): threadid=13: thread exiting, not yet detached (count=0)
09-03 15:38:21.030: D/GStreamer+Piovra(12874): 0:04:05.322372363 0x522ec220 jni/Piovra.c:94:detach_current_thread Detaching thread 0x522ec220
09-03 15:38:21.030: D/GStreamer+Piovra(12874): 0:04:05.323297030 0x521ecd20 jni/Piovra.c:833:gst_native_finalize Deleting GlobalRef for app object at 0x1d200242
09-03 15:38:21.030: D/GStreamer+Piovra(12874): 0:04:05.323552030 0x521ecd20 jni/Piovra.c:835:gst_native_finalize Freeing CustomData at 0x522ec960
09-03 15:38:21.030: D/GStreamer+Piovra(12874): 0:04:05.323775030 0x521ecd20 jni/Piovra.c:838:gst_native_finalize Done finalizing
09-03 15:38:21.280: D/dalvikvm(12874): JIT unchain all for threadid=17
09-03 15:38:21.570: D/dalvikvm(12874): JIT unchain all for threadid=17
After changing of version of gstreamer from Congo to 1.4.0:
09-03 15:29:40.140: D/GStreamer+Piovra(12065): 0:06:52.864815716 0x51e21940 jni/Piovra.c:923:gst_native_pause Setting state to PAUSED
09-03 15:29:40.140: D/GStreamer+Piovra(12065): 0:06:52.864933383 0x51e21940 jni/Piovra.c:113:set_ui_message Setting message to: Setting state to PAUSED
09-03 15:29:40.150: D/GStreamer+Piovra(12065): 0:06:52.877019716 0x51f7cec0 jni/Piovra.c:113:set_ui_message Setting message to: State changed to PAUSED
09-03 15:29:40.150: E/GStreamer+Piovra(12065): 0:06:52.877265716 0x51f7cec0 jni/Piovra.c:117:set_ui_message Failed to call Java method
09-03 15:29:40.660: D/GStreamer+Piovra(12065): 0:06:53.384060383 0x51e21940 jni/Piovra.c:890:gst_native_finalize Quitting video main loop...
09-03 15:29:40.660: D/GStreamer+Piovra(12065): 0:06:53.385065716 0x51e21940 jni/Piovra.c:894:gst_native_finalize Waiting for threads to finish...
09-03 15:29:40.660: D/GStreamer+Piovra(12065): 0:06:53.385104050 0x51f7cec0 jni/Piovra.c:435:video_app_function Exited main loop
09-03 15:29:40.660: W/libEGL(12065): eglTerminate() called w/ 2 objects remaining
09-03 15:29:40.660: D/dalvikvm(12065): threadid=13: thread exiting, not yet detached (count=0)
09-03 15:29:40.660: D/GStreamer+Piovra(12065): 0:06:53.391390716 0x51f7cec0 jni/Piovra.c:94:detach_current_thread Detaching thread 0x51f7cec0
09-03 15:29:40.660: D/GStreamer+Piovra(12065): 0:06:53.392429716 0x51e21940 jni/Piovra.c:900:gst_native_finalize Deleting GlobalRef for app object at 0x1d20023e
09-03 15:29:40.660: D/GStreamer+Piovra(12065): 0:06:53.392723383 0x51e21940 jni/Piovra.c:902:gst_native_finalize Freeing CustomData at 0x51fa0ab8
09-03 15:29:40.660: D/GStreamer+Piovra(12065): 0:06:53.393165383 0x51e21940 jni/Piovra.c:905:gst_native_finalize Done finalizing
09-03 15:29:40.680: E/libEGL(12065): validate_display:253 error 3001 (EGL_NOT_INITIALIZED)
09-03 15:29:40.680: E/libEGL(12065): eglMakeCurrent:511 error 3008 (EGL_BAD_DISPLAY)
09-03 15:29:40.680: E/libEGL(12065): validate_display:253 error 3001 (EGL_NOT_INITIALIZED)
09-03 15:29:40.680: E/libEGL(12065): eglMakeCurrent:511 error 3008 (EGL_BAD_DISPLAY)
09-03 15:30:00.030: E/libEGL(12065): validate_display:253 error 3001 (EGL_NOT_INITIALIZED)
09-03 15:30:00.030: E/libEGL(12065): eglMakeCurrent:511 error 3008 (EGL_BAD_DISPLAY)
09-03 15:30:00.030: E/libEGL(12065): call to OpenGL ES API with no current context (logged once per thread)
09-03 15:30:00.030: E/libEGL(12065): validate_display:253 error 3001 (EGL_NOT_INITIALIZED)
09-03 15:30:00.030: E/libEGL(12065): eglMakeCurrent:511 error 3008 (EGL_BAD_DISPLAY)
09-03 15:30:00.030: W/ManagedEGLContext(12065): doTerminate failed: EGL count is 0 but managed count is 1
Any guesses about?

App force close when executing menu inflater in Android 4.0.4

I built an app base on android api version 8, I choose this option because I think it will work in the newer version of Android, but when I try to do something as I mention in the title I got my app force close. The application starts and works normally, only error in menu inflater, here is my code :
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
Toast.makeText(this, "About Developer", Toast.LENGTH_LONG).show();
Intent i = new Intent(this, about.class);
startActivity(i);
return true;
}
does anyone have any idea to fix it?
Logcat :
09-10 14:07:02.630: DEBUG/AndroidRuntime(1631): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-10 14:07:02.646: DEBUG/AndroidRuntime(1631): CheckJNI is ON
09-10 14:07:10.746: DEBUG/AndroidRuntime(1631): Calling main entry com.android.commands.pm.Pm
09-10 14:07:12.027: DEBUG/dalvikvm(266): GC_EXPLICIT freed 10K, 54% free 2552K/5511K, external 716K/1038K, paused 360ms
09-10 14:07:12.086: WARN/ActivityManager(68): No content provider found for:
09-10 14:07:12.237: WARN/ActivityManager(68): No content provider found for:
09-10 14:07:12.307: DEBUG/PackageParser(68): Scanning package: /data/app/vmdl-674477132.tmp
09-10 14:07:12.707: INFO/PackageManager(68): Removing non-system package:com.dg.tkd
09-10 14:07:12.707: INFO/ActivityManager(68): Force stopping package com.dg.tkd uid=10036
09-10 14:07:12.837: INFO/Process(68): Sending signal. PID: 1618 SIG: 9
09-10 14:07:12.928: ERROR/InputDispatcher(68): channel '4079e2f8 com.dg.tkd/com.dg.tkd.digital_tkd (server)' ~ Consumer closed input channel or an error occurred. events=0x8
09-10 14:07:12.928: ERROR/InputDispatcher(68): channel '4079e2f8 com.dg.tkd/com.dg.tkd.digital_tkd (server)' ~ Channel is unrecoverably broken and will be disposed!
09-10 14:07:12.947: INFO/ActivityManager(68): Force finishing activity HistoryRecord{406a3e48 com.dg.tkd/.digital_tkd}
09-10 14:07:12.986: INFO/WindowManager(68): WIN DEATH: Window{407ea958 com.dg.tkd/com.dg.tkd.about paused=false}
09-10 14:07:13.037: INFO/WindowManager(68): WIN DEATH: Window{4079e2f8 com.dg.tkd/com.dg.tkd.digital_tkd paused=false}
09-10 14:07:13.086: ERROR/InputDispatcher(68): Received spurious receive callback for unknown input channel. fd=161, events=0x8
09-10 14:07:13.447: DEBUG/dalvikvm(68): GC_CONCURRENT freed 1043K, 46% free 4596K/8455K, external 3251K/3627K, paused 24ms+31ms
09-10 14:07:13.788: DEBUG/PackageManager(68): Scanning package com.dg.tkd
09-10 14:07:13.788: INFO/ActivityManager(68): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=1641 uid=10001 gids={}
09-10 14:07:13.836: INFO/PackageManager(68): Package com.dg.tkd codePath changed from /data/app/com.dg.tkd-1.apk to /data/app/com.dg.tkd-2.apk; Retaining data and using new
09-10 14:07:14.146: INFO/PackageManager(68): Unpacking native libraries for /data/app/com.dg.tkd-2.apk
09-10 14:07:14.707: DEBUG/installd(35): DexInv: --- BEGIN '/data/app/com.dg.tkd-2.apk' ---
09-10 14:07:15.457: DEBUG/dalvikvm(1649): DexOpt: load 72ms, verify+opt 125ms
09-10 14:07:15.537: DEBUG/installd(35): DexInv: --- END '/data/app/com.dg.tkd-2.apk' (success) ---
09-10 14:07:15.546: WARN/PackageManager(68): Code path for pkg : com.dg.tkd changing from /data/app/com.dg.tkd-1.apk to /data/app/com.dg.tkd-2.apk
09-10 14:07:15.546: WARN/PackageManager(68): Resource path for pkg : com.dg.tkd changing from /data/app/com.dg.tkd-1.apk to /data/app/com.dg.tkd-2.apk
09-10 14:07:15.546: DEBUG/PackageManager(68): Activities: com.dg.tkd.digital_tkd com.dg.tkd.about
09-10 14:07:15.747: INFO/installd(35): move /data/dalvik-cache/data#app#com.dg.tkd-2.apk#classes.dex -> /data/dalvik-cache/data#app#com.dg.tkd-2.apk#classes.dex
09-10 14:07:15.757: DEBUG/PackageManager(68): New package installed in /data/app/com.dg.tkd-2.apk
09-10 14:07:16.047: INFO/WindowManager(68): Setting rotation to 0, animFlags=1
09-10 14:07:16.146: INFO/ActivityManager(68): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=1 layout=18 uiMode=17 seq=48}
09-10 14:07:16.717: INFO/ActivityManager(68): Force stopping package com.dg.tkd uid=10036
09-10 14:07:17.717: INFO/ActivityThread(1641): Pub com.android.launcher2.settings: com.android.launcher2.LauncherProvider
09-10 14:07:19.727: DEBUG/dalvikvm(1641): GC_EXTERNAL_ALLOC freed 457K, 54% free 2684K/5767K, external 1032K/1038K, paused 107ms
09-10 14:07:20.607: INFO/ActivityManager(68): Displayed com.android.launcher/com.android.launcher2.Launcher: +7s521ms
09-10 14:07:20.687: WARN/InputManagerService(68): Got RemoteException sending setActive(false) notification to pid 1618 uid 10036
09-10 14:07:21.156: WARN/WindowManager(68): App freeze timeout expired.
09-10 14:07:21.657: INFO/ActivityManager(68): Force stopping package com.dg.tkd uid=10036
09-10 14:07:22.097: DEBUG/dalvikvm(1641): GC_EXTERNAL_ALLOC freed 97K, 53% free 2718K/5767K, external 1561K/1572K, paused 229ms
09-10 14:07:22.256: DEBUG/dalvikvm(68): GC_EXPLICIT freed 514K, 47% free 4504K/8455K, external 3247K/3627K, paused 397ms
09-10 14:07:23.517: DEBUG/dalvikvm(68): GC_EXPLICIT freed 18K, 47% free 4486K/8455K, external 3247K/3627K, paused 240ms
09-10 14:07:25.356: WARN/RecognitionManagerService(68): no available voice recognition services found
09-10 14:07:26.056: DEBUG/dalvikvm(68): GC_EXPLICIT freed 129K, 47% free 4515K/8455K, external 3247K/3627K, paused 391ms
09-10 14:07:26.906: INFO/installd(35): unlink /data/dalvik-cache/data#app#com.dg.tkd-1.apk#classes.dex
09-10 14:07:27.037: DEBUG/AndroidRuntime(1631): Shutting down VM
09-10 14:07:27.097: INFO/AndroidRuntime(1631): NOTE: attach of thread 'Binder Thread #4' failed
09-10 14:07:27.117: DEBUG/dalvikvm(1631): GC_CONCURRENT freed 100K, 72% free 293K/1024K, external 0K/0K, paused 16ms+18ms
09-10 14:07:27.157: DEBUG/dalvikvm(1631): Debugger has detached; object registry had 1 entries
09-10 14:07:29.029: DEBUG/AndroidRuntime(1657): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
09-10 14:07:29.029: DEBUG/AndroidRuntime(1657): CheckJNI is ON
09-10 14:07:30.966: DEBUG/dalvikvm(1641): GC_CONCURRENT freed 224K, 50% free 2915K/5767K, external 1959K/2091K, paused 9ms+9ms
09-10 14:07:31.826: DEBUG/AndroidRuntime(1657): Calling main entry com.android.commands.am.Am
09-10 14:07:32.726: INFO/ActivityManager(68): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.dg.tkd/.digital_tkd } from pid 1657
09-10 14:07:32.857: DEBUG/AndroidRuntime(1657): Shutting down VM
09-10 14:07:32.926: INFO/AndroidRuntime(1657): NOTE: attach of thread 'Binder Thread #3' failed
09-10 14:07:33.037: DEBUG/dalvikvm(1657): GC_CONCURRENT freed 102K, 69% free 319K/1024K, external 0K/0K, paused 4ms+2ms
09-10 14:07:33.108: DEBUG/jdwp(1657): Got wake-up signal, bailing out of select
09-10 14:07:33.108: DEBUG/dalvikvm(1657): Debugger has detached; object registry had 1 entries
09-10 14:07:33.327: WARN/ActivityManager(68): Activity pause timeout for HistoryRecord{40796458 com.android.launcher/com.android.launcher2.Launcher}
09-10 14:07:33.446: INFO/ActivityManager(68): Start proc com.dg.tkd for activity com.dg.tkd/.digital_tkd: pid=1666 uid=10036 gids={}
09-10 14:07:34.347: INFO/WindowManager(68): Setting rotation to 1, animFlags=1
09-10 14:07:34.386: INFO/ActivityManager(68): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=2 layout=18 uiMode=17 seq=49}
09-10 14:07:35.997: INFO/ActivityManager(68): Displayed com.dg.tkd/.digital_tkd: +2s584ms
09-10 14:07:37.786: DEBUG/dalvikvm(266): GC_EXPLICIT freed 8K, 54% free 2551K/5511K, external 716K/1038K, paused 381ms
09-10 14:07:38.046: WARN/IInputConnectionWrapper(1641): showStatusIcon on inactive InputConnection
09-10 14:07:38.337: DEBUG/dalvikvm(1641): GC_EXTERNAL_ALLOC freed 33K, 50% free 2899K/5767K, external 1953K/2091K, paused 88ms
09-10 14:07:38.896: DEBUG/dalvikvm(68): GC_EXPLICIT freed 298K, 47% free 4490K/8455K, external 3247K/3627K, paused 172ms
09-10 14:07:40.007: DEBUG/dalvikvm(1641): GC_EXTERNAL_ALLOC freed 48K, 50% free 2891K/5767K, external 2754K/2940K, paused 104ms
09-10 14:07:41.847: DEBUG/dalvikvm(317): GC_EXPLICIT freed 12K, 55% free 2578K/5703K, external 716K/1038K, paused 167ms
09-10 14:07:45.489: INFO/ActivityManager(68): Process android.process.media (pid 210) has died.
09-10 14:07:47.356: DEBUG/dalvikvm(341): GC_EXPLICIT freed 5K, 55% free 2520K/5511K, external 716K/1038K, paused 644ms
09-10 14:07:49.816: DEBUG/dalvikvm(1641): GC_EXTERNAL_ALLOC freed 9K, 51% free 2882K/5767K, external 5999K/7492K, paused 167ms
09-10 14:08:18.196: WARN/KeyCharacterMap(1666): No keyboard for id 0
09-10 14:08:18.196: WARN/KeyCharacterMap(1666): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-10 14:08:21.546: INFO/ActivityManager(68): Starting: Intent { cmp=com.dg.tkd/.about } from pid 1666
09-10 14:08:22.097: DEBUG/dalvikvm(1666): GC_EXTERNAL_ALLOC freed 65K, 52% free 2608K/5379K, external 908K/1038K, paused 97ms
09-10 14:08:23.776: INFO/ActivityManager(68): Displayed com.dg.tkd/.about: +2s112ms

My application works on android emulator but not on my device

My application is running on the emulator no problem, but it does not work on my handset,
Samsung Galaxy Nexus S.
The application consist of different logins, including, Facebook, Twitter, Mendeley and my own web application.
I do not know why it is not working. On Facebook, in application settings I have also added the hash code required but it really does not work. Maybe it is something related to http request(s) to the servers from the device. Stressed about it, please help
Here are the logs
07-18 23:23:32.826: D/AndroidRuntime(430): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-18 23:23:32.826: D/AndroidRuntime(430): CheckJNI is ON
07-18 23:23:33.725: D/AndroidRuntime(430): Calling main entry com.android.commands.pm.Pm
07-18 23:23:33.965: D/dalvikvm(249): GC_EXPLICIT freed 3K, 54% free 2545K/5511K, external 1625K/2137K, paused 77ms
07-18 23:23:33.965: W/ActivityManager(67): No content provider found for:
07-18 23:23:34.371: W/ActivityManager(67): No content provider found for:
07-18 23:23:34.405: D/PackageParser(67): Scanning package: /data/app/vmdl-873505620.tmp
07-18 23:23:34.745: I/PackageManager(67): Removing non-system package:com.facebook.android
07-18 23:23:34.745: I/ActivityManager(67): Force stopping package com.facebook.android uid=10034
07-18 23:23:34.865: I/Process(67): Sending signal. PID: 401 SIG: 9
07-18 23:23:34.865: I/ActivityManager(67): Force finishing activity HistoryRecord{4059c7a0 com.facebook.android/.PushpinMobileActivity}
07-18 23:23:35.072: I/WindowManager(67): WIN DEATH: Window{40718cf0 com.facebook.android/com.facebook.android.PushpinMobileActivity paused=true}
07-18 23:23:35.085: E/InputDispatcher(67): channel '407dd068 com.facebook.android/com.facebook.android.Dashboard (server)' ~ Consumer closed input channel or an error occurred. events=0x8
07-18 23:23:35.085: E/InputDispatcher(67): channel '407dd068 com.facebook.android/com.facebook.android.Dashboard (server)' ~ Channel is unrecoverably broken and will be disposed!
07-18 23:23:35.145: I/WindowManager(67): WIN DEATH: Window{407dd068 com.facebook.android/com.facebook.android.Dashboard paused=false}
07-18 23:23:35.456: D/PackageManager(67): Scanning package com.facebook.android
07-18 23:23:35.485: I/PackageManager(67): Package com.facebook.android codePath changed from /data/app/com.facebook.android-1.apk to /data/app/com.facebook.android-2.apk; Retaining data and using new
07-18 23:23:35.526: I/PackageManager(67): Unpacking native libraries for /data/app/com.facebook.android-2.apk
07-18 23:23:35.715: W/InputManagerService(67): Got RemoteException sending setActive(false) notification to pid 401 uid 10034
07-18 23:23:36.130: D/installd(34): DexInv: --- BEGIN '/data/app/com.facebook.android-2.apk' ---
07-18 23:23:38.285: D/dalvikvm(439): DexOpt: load 135ms, verify+opt 948ms
07-18 23:23:38.646: D/installd(34): DexInv: --- END '/data/app/com.facebook.android-2.apk' (success) ---
07-18 23:23:38.646: W/PackageManager(67): Code path for pkg : com.facebook.android changing from /data/app/com.facebook.android-1.apk to /data/app/com.facebook.android-2.apk
07-18 23:23:38.646: W/PackageManager(67): Resource path for pkg : com.facebook.android changing from /data/app/com.facebook.android-1.apk to /data/app/com.facebook.android-2.apk
07-18 23:23:38.655: D/PackageManager(67): Activities: com.facebook.android.PushpinMobileActivity com.facebook.android.OAuthAccessTokenActivity com.facebook.android.Dashboard com.facebook.android.MendeleyAcessTokenActivity
07-18 23:23:38.845: D/dalvikvm(67): GC_FOR_MALLOC freed 1240K, 48% free 4374K/8391K, external 3520K/3903K, paused 185ms
07-18 23:23:38.855: I/ActivityManager(67): Force stopping package com.facebook.android uid=10034
07-18 23:23:39.180: I/installd(34): move /data/dalvik-cache/data#app#com.facebook.android-2.apk#classes.dex -> /data/dalvik-cache/data#app#com.facebook.android-2.apk#classes.dex
07-18 23:23:39.180: D/PackageManager(67): New package installed in /data/app/com.facebook.android-2.apk
07-18 23:23:39.576: I/ActivityManager(67): Force stopping package com.facebook.android uid=10034
07-18 23:23:39.795: D/dalvikvm(159): GC_EXPLICIT freed 194K, 50% free 2942K/5831K, external 2985K/3727K, paused 205ms
07-18 23:23:39.915: D/dalvikvm(131): GC_EXPLICIT freed 68K, 50% free 2964K/5895K, external 4803K/5279K, paused 183ms
07-18 23:23:40.285: D/dalvikvm(183): GC_EXPLICIT freed 128K, 52% free 2758K/5703K, external 1625K/2137K, paused 422ms
07-18 23:23:40.445: I/dalvikvm(159): Jit: resizing JitTable from 512 to 1024
07-18 23:23:40.545: W/RecognitionManagerService(67): no available voice recognition services found
07-18 23:23:41.105: D/dalvikvm(67): GC_EXPLICIT freed 424K, 49% free 4285K/8391K, external 3511K/3903K, paused 108ms
07-18 23:23:41.245: I/installd(34): unlink /data/dalvik-cache/data#app#com.facebook.android-1.apk#classes.dex
07-18 23:23:41.295: D/AndroidRuntime(430): Shutting down VM
07-18 23:23:41.327: I/AndroidRuntime(430): NOTE: attach of thread 'Binder Thread #3' failed
07-18 23:23:41.335: D/dalvikvm(430): GC_CONCURRENT freed 101K, 72% free 295K/1024K, external 0K/0K, paused 3ms+1ms
07-18 23:23:41.335: D/jdwp(430): Got wake-up signal, bailing out of select
07-18 23:23:41.335: D/dalvikvm(430): Debugger has detached; object registry had 1 entries
07-18 23:23:41.545: I/Launcher(131): setLoadOnResume
07-18 23:23:42.055: D/AndroidRuntime(444): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-18 23:23:42.055: D/AndroidRuntime(444): CheckJNI is ON
07-18 23:23:42.985: D/AndroidRuntime(444): Calling main entry com.android.commands.am.Am
07-18 23:23:43.066: I/ActivityManager(67): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.facebook.android/.PushpinMobileActivity } from pid 444
07-18 23:23:43.135: I/ActivityManager(67): Start proc com.facebook.android for activity com.facebook.android/.PushpinMobileActivity: pid=452 uid=10034 gids={3003}
07-18 23:23:43.155: D/AndroidRuntime(444): Shutting down VM
07-18 23:23:43.175: D/dalvikvm(444): GC_CONCURRENT freed 102K, 69% free 320K/1024K, external 0K/0K, paused 4ms+1ms
07-18 23:23:43.205: I/AndroidRuntime(444): NOTE: attach of thread 'Binder Thread #3' failed
07-18 23:23:43.205: D/jdwp(444): Got wake-up signal, bailing out of select
07-18 23:23:43.205: D/dalvikvm(444): Debugger has detached; object registry had 1 entries
07-18 23:23:43.585: D/dalvikvm(32): GC_EXPLICIT freed 11K, 53% free 2538K/5379K, external 1625K/2137K, paused 456ms
07-18 23:23:43.755: D/dalvikvm(32): GC_EXPLICIT freed <1K, 53% free 2538K/5379K, external 1625K/2137K, paused 168ms
07-18 23:23:44.097: D/dalvikvm(32): GC_EXPLICIT freed <1K, 53% free 2538K/5379K, external 1625K/2137K, paused 324ms
07-18 23:23:44.567: I/ActivityManager(67): Displayed com.facebook.android/.PushpinMobileActivity: +1s447ms
07-18 23:23:45.145: W/IInputConnectionWrapper(159): showStatusIcon on inactive InputConnection
07-18 23:23:49.746: D/dalvikvm(237): GC_EXPLICIT freed 18K, 55% free 2597K/5703K, external 1625K/2137K, paused 85ms
07-18 23:23:54.886: D/dalvikvm(159): GC_EXPLICIT freed 23K, 50% free 2944K/5831K, external 3005K/3727K, paused 145ms
07-18 23:23:59.906: D/dalvikvm(249): GC_EXPLICIT freed 6K, 54% free 2544K/5511K, external 1625K/2137K, paused 111ms
07-18 23:24:05.186: D/dalvikvm(311): GC_EXPLICIT freed 3K, 54% free 2537K/5511K, external 1625K/2137K, paused 50ms
07-18 23:24:20.515: D/dalvikvm(452): GC_EXTERNAL_ALLOC freed 819K, 56% free 2723K/6151K, external 1793K/2137K, paused 74ms
07-18 23:24:25.196: W/InputManagerService(67): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#40658160
07-18 23:24:30.906: I/Database(452): sqlite returned: error code = 14, msg = cannot open file at source line 25467
07-18 23:24:35.826: W/InputManagerService(67): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#406c8c70
07-18 23:24:53.035: D/dalvikvm(452): GC_CONCURRENT freed 1052K, 55% free 3042K/6727K, external 2079K/2562K, paused 20ms+11ms
07-18 23:25:03.306: I/fbID(452): 518993454
07-18 23:25:03.316: I/fb_token(452): <....>
07-18 23:25:03.436: D/dalvikvm(452): GC_CONCURRENT freed 803K, 55% free 3093K/6727K, external 2079K/2562K, paused 16ms+6ms
07-18 23:25:04.426: I/dalvikvm(452): Jit: resizing JitTable from 512 to 1024
07-18 23:25:08.706: I/System.out(452): Access Token =
07-18 23:25:08.716: I/System.out(452): Backend Response to Token Request:
07-18 23:25:08.727: I/System.out(452): Access Token = <....>
07-18 23:25:08.727: I/System.out(452): UserID = 70
07-18 23:25:08.727: I/System.out(452): Username = <....>
07-18 23:25:08.727: I/System.out(452): Expiration Timestamp = 1342697101
07-18 23:25:08.727: I/System.out(452): Facebook Token = <....>
07-18 23:25:08.727: I/System.out(452): Twitter Token = <....>
07-18 23:25:08.727: I/System.out(452): Twitter Token Secret = <....>
07-18 23:25:08.727: I/System.out(452): Mendeley Token =
07-18 23:25:08.739: I/System.out(452): Mendeley Token Secret =
07-18 23:25:08.817: I/ActivityManager(67): Starting: Intent { cmp=com.facebook.android/.Dashboard (has extras) } from pid 452
07-18 23:25:09.586: I/System.out(452): Got it! Lets see what we found...
07-18 23:25:09.586: I/System.out(452): 200
07-18 23:25:09.656: D/dalvikvm(452): GC_FOR_MALLOC freed 405K, 55% free 3043K/6727K, external 2129K/2562K, paused 70ms
07-18 23:25:12.706: D/dalvikvm(452): GC_FOR_MALLOC freed 58K, 53% free 3220K/6727K, external 2150K/2562K, paused 78ms
07-18 23:25:12.706: I/dalvikvm-heap(452): Grow heap (frag case) to 7.872MB for 87396-byte allocation
07-18 23:25:12.846: D/dalvikvm(452): GC_FOR_MALLOC freed <1K, 52% free 3306K/6855K, external 2150K/2562K, paused 66ms
07-18 23:25:13.026: D/dalvikvm(452): GC_FOR_MALLOC freed 0K, 52% free 3306K/6855K, external 2150K/2562K, paused 106ms
07-18 23:25:13.026: I/dalvikvm-heap(452): Grow heap (frag case) to 7.956MB for 87396-byte allocation
07-18 23:25:13.216: D/dalvikvm(452): GC_FOR_MALLOC freed 0K, 52% free 3391K/6983K, external 2150K/2562K, paused 123ms
07-18 23:25:13.596: W/ImageDownloader(452): Incorrect URL:
07-18 23:25:13.746: D/dalvikvm(452): GC_FOR_MALLOC freed 234K, 53% free 3319K/6983K, external 2272K/2562K, paused 57ms
07-18 23:25:14.956: I/ActivityManager(67): Displayed com.facebook.android/.Dashboard: +5s947ms
The problem was coming because I was using webview for Mendeley and Twitter on Android using scribe library. And I have solved it here
android webview function onPagefinished is called twice
And for Facebook the problem was because I was not adding the correct hash key the method given on Facebook page for Windows does not give you correct hash key. Please install openSSL to generate the key.

Consumer closed input channel or an error occurred. events=0x8

D/AndroidRuntime(11752):
D/AndroidRuntime(11752): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(11752): CheckJNI is ON
D/dalvikvm(11752): creating instr width table
E/jdwp (11752): pipe failed
W/ProcessState(11752): Opening '/dev/binder' failed: Too many open files
D/AndroidRuntime(11752): Calling main entry com.android.commands.am.Am
I/Mamarduke_Diag( 1726): Data is available now.
I/Mamarduke_Diag( 1726): exec result -->>> java.lang.NullPointerException
I/DMIC ( 1726): ---> java.lang.NullPointerException
I/System.out( 1726): *****wifi state end=1
D/dalvikvm( 1726): GC_EXPLICIT freed 31K, 41% free 7507K/12551K, external 1625K/2137K, paused 58ms
D/dalvikvm( 1726): GC_EXPLICIT freed 0K, 41% free 7507K/12551K, external 1625K/2137K, paused 58ms
I/System.out( 1726): ***run in test i=7,camera
I/System.out( 1726): ***run in test i=8,cec
I/System.out( 1726): ***run in test i=9,edid
I/System.out( 1726): *****wifi state start=1
I/Mamarduke_Diag( 1726): Data is available now.
I/Mamarduke_Diag( 1726): exec result -->>>
I/System.out( 1726): *****wifi state end=1
D/dalvikvm( 1726): GC_EXPLICIT freed 36K, 41% free 7474K/12551K, external 1625K/2137K, paused 57ms
D/dalvikvm( 1726): GC_EXPLICIT freed 0K, 41% free 7474K/12551K, external 1625K/2137K, paused 58ms
I/System.out( 1726): ***run in test i=10,iris
I/System.out( 1726): *****wifi state start=1
I/ActivityManager( 1491): Starting: Intent { act=com.android.camera.irison flg=0x10000000 cmp=com.ianc.apd/.testcase.cameraex.ImageCamera } from pid 1726
I/System.out( 1726): onCreate
I/System.out( 1726): onResume
I/System.out( 1726): test irist on
I/System.out( 1726): excuteCmd/sys/bus/spi/devices/spi2.0/irisstate
E/InputDispatcher( 1491): channel '40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera (server)' ~ Consumer closed input channel or an error occurred. events=0x8
E/InputDispatcher( 1491): channel '40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera (server)' ~ Channel is unrecoverably broken and will be disposed!
D/AndroidRuntime( 1726): Shutting down VM
W/dalvikvm( 1726): threadid=1: thread exiting with uncaught exception (group=0x40015560)
I/WindowManager( 1491): WINDOW DIED Window{40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera paused=false}
E/AndroidRuntime( 1726): FATAL EXCEPTION: main
E/AndroidRuntime( 1726): java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
E/AndroidRuntime( 1726): at android.view.InputChannel.nativeReadFromParcel(Native Method)
E/AndroidRuntime( 1726): at android.view.InputChannel.readFromParcel(InputChannel.java:138)
E/AndroidRuntime( 1726): at android.view.IWindowSession$Stub$Proxy.add(IWindowSession.java:409)
E/AndroidRuntime( 1726): at android.view.ViewRoot.setView(ViewRoot.java:498)
E/AndroidRuntime( 1726): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
E/AndroidRuntime( 1726): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/AndroidRuntime( 1726): at android.view.Window$LocalWindowManager.addView(Window.java:424)
E/AndroidRuntime( 1726): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2170)
E/AndroidRuntime( 1726): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
E/AndroidRuntime( 1726): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 1726): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 1726): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1726): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 1726): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 1726): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1726): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 1726): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 1726): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 1726): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 1491): Force finishing activity com.ianc.apd/.testcase.cameraex.ImageCamera
W/ActivityManager( 1491): Activity pause timeout for HistoryRecord{4069a248 com.ianc.apd/.testcase.cameraex.ImageCamera}
Why do Consumer closed input channel or an error occurred. events=0x8 happen after many times running? That is too say, my program can run at first, but after many times, the exception happen.
I read this: Input transport and input dispatcher error on 2.3, but I have no idea how to solve it!! Who can help me?
I run my program in real device. The android version is 2.3
Update 1:
I found the root cause of Could not read input channel file descriptors from parcel.
It is E/jdwp (11752): pipe failed.
Why do create pipe failed? Because the pipe is out of the max in the system. that is to say, we create a lot of pipe or file descriptors in the system. And then we found the reason and try to modify it: My friend change the code like that in his Activity: `Original source code:
private class MyHandler extends Handler {
MyHandler(Looper looper) {
super(looper);
}
#Override
public void handleMessage(Message msg) {
switch(msg.what) {
case RELEASE_CAMERA:
synchronized (CameraHolder.this) {
// In 'CameraHolder.open', the 'RELEASE_CAMERA' message
// will be removed if it is found in the queue. However,
// there is a chance that this message has been handled
// before being removed. So, we need to add a check
// here:
if (CameraHolder.this.mUsers == 0) releaseCamera();
}
break;
}
}
}
...
HandlerThread ht = new HandlerThread("CameraHolder");
ht.start();
mHandler = new MyHandler(ht.getLooper());
change to
private class MyHandler extends Handler {
MyHandler(Looper looper) {
super(looper);
}
#Override
public void handleMessage(Message msg) {
switch(msg.what) {
case RELEASE_CAMERA:
synchronized (CameraHolder.this) {
// In 'CameraHolder.open', the 'RELEASE_CAMERA' message
// will be removed if it is found in the queue. However,
// there is a chance that this message has been handled
// before being removed. So, we need to add a check
// here:
if (CameraHolder.this.mUsers == 0) releaseCamera();
}
break;
}
}
}
mHandler = new MyHandler();
Those file descriptors will reduce obviously. Why? how to explain this case? And I add mHandler.removemessage this function to onPause in my Activity. And Those file descriptors also reduce obviously. why? who can explain this case for me? I am trying to understand this.
Benni05 found a solution here, by setting android:configChanges="orientation" property for activity #AndroidManifest. It work for me(where i get an error with api lvl.11 installed devices). Good luck!
it is most probably because of having a wrong xml resource file. for me i put colors in strings.xml and got this errors. then i created colors.xml and now it works.

NullPointerException in background thread when attempting to call messenger

I'm testing a simple Android app that uses a Service, Thread, and Messenger. I noticed when I quickly start and stop the Service I sometimes get a NullPointerException and FORCE CLOSE. I debugged it and found out my Messenger instance is sometimes null and thus my handler does not get called. What am I doing wrong? Do I need to wait before restarting the Service?
OK it just now happened without the quick stop/start of the Service. So I am not sure how to reproduce this problem. It may occur randomly.
I can catch the exception and get rid of the FORCE CLOSE, but that does not solve my problem of my handler not getting called when the Messenger instance is null. I looked at the Services documentation section on Managing the Lifecycle of a Service, and I did not see any mention of having to wait before restarting a Service.
This is how I start my Service:
Intent backgroundService = new Intent(PlayAudio.this, com.marie.mp3player.BackgroundService.class);
backgroundService.putExtra(BackgroundService.EXTRA_MESSENGER, new Messenger(handler));
backgroundService.putExtra(BackgroundService.EXTRA_SONG, song);
startService(backgroundService);
This is how I stop my Service:
Intent backgroundService = new Intent(MP3Player.this, BackgroundService.class);
stopService(backgroundService);
And here is a logcat containing two NullPointerExceptions near the bottom:
D/AndroidRuntime(17736):
D/AndroidRuntime(17736): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(17736): CheckJNI is OFF
D/dalvikvm(17736): creating instr width table
D/AndroidRuntime(17736): Calling main entry com.android.commands.pm.Pm
I/ActivityManager( 96): Start proc com.android.defcontainer for service com.android.defcontainer/.DefaultContainerService: pid=17744 uid=10011 gids={1015, 2001}
D/dalvikvm(17744): GC_EXPLICIT freed 46K, 50% free 2720K/5379K, external 1625K/2137K, paused 34ms
W/ActivityManager( 96): No content provider found for:
D/PackageParser( 96): Scanning package: /data/app/vmdl-1782488429.tmp
W/ActivityManager( 96): No content provider found for:
I/PackageManager( 96): Removing non-system package:com.marie.mp3player
I/ActivityManager( 96): Force stopping package com.marie.mp3player uid=10091
D/PackageManager( 96): Scanning package com.marie.mp3player
I/PackageManager( 96): Package com.marie.mp3player codePath changed from /data/app/com.marie.mp3player-2.apk to /data/app/com.marie.mp3player-1.apk; Retaining data and using new
I/PackageManager( 96): Unpacking native libraries for /data/app/com.marie.mp3player-1.apk
D/installd( 70): DexInv: --- BEGIN '/data/app/com.marie.mp3player-1.apk' ---
D/dalvikvm(17752): creating instr width table
D/dalvikvm(17752): DexOpt: load 5ms, verify+opt 18ms
D/installd( 70): DexInv: --- END '/data/app/com.marie.mp3player-1.apk' (success) ---
D/PackageManager( 96): Services: com.marie.mp3player.BackgroundService
D/PackageManager( 96): Activities: com.marie.mp3player.MP3Player com.marie.mp3player.PlayAudio
I/ActivityManager( 96): Force stopping package com.marie.mp3player uid=10091
W/PackageManager( 96): Code path for pkg : com.marie.mp3player changing from /data/app/com.marie.mp3player-2.apk to /data/app/com.marie.mp3player-1.apk
W/PackageManager( 96): Resource path for pkg : com.marie.mp3player changing from /data/app/com.marie.mp3player-2.apk to /data/app/com.marie.mp3player-1.apk
I/installd( 70): move /data/dalvik-cache/data#app#com.marie.mp3player-1.apk#classes.dex -> /data/dalvik-cache/data#app#com.marie.mp3player-1.apk#classes.dex
D/PackageManager( 96): New package installed in /data/app/com.marie.mp3player-1.apk
I/ActivityManager( 96): Force stopping package com.marie.mp3player uid=10091
D/dalvikvm( 96): GC_EXPLICIT freed 842K, 41% free 6421K/10759K, external 2424K/3027K, paused 106ms
D/dalvikvm( 192): GC_EXPLICIT freed 16K, 45% free 4617K/8327K, external 15977K/17649K, paused 67ms
D/dalvikvm( 158): GC_EXPLICIT freed 525K, 54% free 3151K/6791K, external 2480K/3071K, paused 49ms
I/ActivityManager( 96): Start proc com.appspot.swisscodemonkeys.apps for broadcast com.appspot.swisscodemonkeys.apps/.PackageReceiver: pid=17753 uid=10084 gids={3003}
I/ActivityThread(17753): Pub appbrain.SuggestionProvider: com.appspot.swisscodemonkeys.apps.search.SearchSuggestionSampleProvider
D/dalvikvm(11468): GC_EXPLICIT freed 2K, 49% free 2965K/5767K, external 1625K/2137K, paused 314ms
I/ActivityManager( 96): Start proc com.noshufou.android.su for broadcast com.noshufou.android.su/.UninstallReceiver: pid=17761 uid=10056 gids={1015, 3003}
D/dalvikvm( 96): GC_EXPLICIT freed 273K, 41% free 6367K/10759K, external 2424K/3027K, paused 101ms
I/installd( 70): unlink /data/dalvik-cache/data#app#com.marie.mp3player-2.apk#classes.dex
D/AndroidRuntime(17736): Shutting down VM
D/dalvikvm(17736): GC_CONCURRENT freed 101K, 72% free 296K/1024K, external 0K/0K, paused 0ms+1ms
D/jdwp (17736): Got wake-up signal, bailing out of select
D/dalvikvm(17736): Debugger has detached; object registry had 1 entries
I/ActivityManager( 96): Start proc com.android.voicedialer for broadcast com.android.voicedialer/.VoiceDialerReceiver: pid=17770 uid=10048 gids={3002}
D/VoiceDialerReceiver(17770): onReceive Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.marie.mp3player flg=0x10000000 cmp=com.android.voicedialer/.VoiceDialerReceiver (has extras) }
V/RecognizerEngine(17770): deleteCachedGrammarFiles /data/data/com.android.voicedialer/files/openentries.txt
I/ActivityManager( 96): Start proc com.android.vending for broadcast com.android.vending/.PackageMonitorReceiver: pid=17779 uid=10046 gids={1015, 3003}
D/dalvikvm( 67): GC_EXPLICIT freed 11K, 50% free 2717K/5379K, external 1625K/2137K, paused 94ms
D/dalvikvm( 67): GC_EXPLICIT freed <1K, 50% free 2717K/5379K, external 1625K/2137K, paused 81ms
I/ActivityThread(17779): Pub com.android.vending.SuggestionsProvider: com.android.vending.SuggestionsProvider
D/vending (17779): [1] VendingApplication.onCreate(): Resetting ServiceLocator from app
D/dalvikvm( 67): GC_EXPLICIT freed <1K, 50% free 2717K/5379K, external 1625K/2137K, paused 93ms
D/InstallReceiver(17761): com.marie.mp3player
I/ActivityManager( 96): Start proc com.google.android.partnersetup for broadcast com.google.android.partnersetup/.AppInstalledReceiver: pid=17791 uid=10021 gids={}
D/AndroidRuntime(17783):
D/AndroidRuntime(17783): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(17783): CheckJNI is OFF
D/dalvikvm(17783): creating instr width table
D/GTalkService( 211): handlePackageInstalled: re-initialize providers
D/GTalkService( 211): [RawStanzaProvidersMgr] ##### searchProvidersFromIntent
D/GTalkService( 211): [RawStanzaProvidersMgr] no intent receivers found
D/VoiceDialerReceiver(17770): onReceive Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.marie.mp3player flg=0x10000000 cmp=com.android.voicedialer/.VoiceDialerReceiver (has extras) }
V/RecognizerEngine(17770): deleteCachedGrammarFiles /data/data/com.android.voicedialer/files/openentries.txt
I/ActivityManager( 96): Start proc com.google.android.googlequicksearchbox for broadcast com.google.android.googlequicksearchbox/.CorporaUpdateReceiver: pid=17798 uid=10022 gids={3003}
I/ActivityThread(17798): Pub com.google.android.googlequicksearchbox.shortcuts: com.google.android.googlequicksearchbox.ShortcutsProvider
I/ActivityThread(17798): Pub com.google.android.googlequicksearchbox.google: com.google.android.googlequicksearchbox.google.GoogleSuggestionProvider
I/ActivityManager( 96): Start proc com.google.android.apps.maps:FriendService for broadcast com.google.android.apps.maps/com.google.googlenav.friend.android.ServiceReceiver: pid=17812 uid=10033 gids={3003, 1015}
D/AndroidRuntime(17783): Calling main entry com.android.commands.am.Am
I/ActivityManager( 96): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.marie.mp3player/.MP3Player } from pid 17783
D/AndroidRuntime(17783): Shutting down VM
D/dalvikvm(17783): GC_CONCURRENT freed 102K, 69% free 320K/1024K, external 0K/0K, paused 0ms+0ms
D/jdwp (17783): Got wake-up signal, bailing out of select
D/dalvikvm(17783): Debugger has detached; object registry had 1 entries
I/ActivityManager( 96): Start proc com.marie.mp3player for activity com.marie.mp3player/.MP3Player: pid=17822 uid=10091 gids={}
I/AndroidRuntime(17783): NOTE: attach of thread 'Binder Thread #3' failed
I/ActivityManager( 96): Start proc com.google.android.apps.maps:NetworkLocationService for service com.google.android.apps.maps/com.google.android.location.internal.server.NetworkLocationService: pid=17830 uid=10033 gids={3003, 1015}
I/ActivityManager( 96): Displayed com.marie.mp3player/.MP3Player: +429ms
I/ActivityManager( 96): Start proc com.noinnion.android.greader.readerpro for broadcast com.noinnion.android.greader.readerpro/.OnUpgradeReceiver: pid=17831 uid=10070 gids={3003, 1015}
V/RenderScript_jni( 192): surfaceDestroyed
I/ActivityThread(17831): Pub com.noinnion.android.greader.readerpro: com.noinnion.android.greader.readerpro.ReaderProvider
D/InternalNlpService(17830): onCreate
D/NetworkLocationServiceThread(17830): start monitoring enabled
D/NetworkLocationServiceThread(17830): updateState
D/NetworkLocationServiceThread(17830): Creating RealOs
D/vending (17779): [11] LocalAssetCache.updateOnePackage(): No local info for com.marie.mp3player
D/szipinf (17830): Initializing inflate state
D/szipinf (17830): Initializing zlib to inflate
D/vending (17779): [12] LocalAssetCache.updateOnePackage(): No local info for com.marie.mp3player
D/dalvikvm(17830): GC_CONCURRENT freed 460K, 43% free 3851K/6727K, external 1625K/2137K, paused 2ms+3ms
D/WifiLocator(17830): Too many cache misses. Need server request. hasLocation=0 noLocation=1 cacheMiss=2
I/System.out(17830): [INFO:1747]: f: Running flush
I/System.out(17830): [INFO:1761]: f: Sending payload [bytes=300]
I/System.out(17830): [INFO:6772]: f: Running flush
I/System.out(17830): [INFO:6761]: f: Running delayed flush
I/ActivityManager( 96): Start proc org.my_pod.mypod for service org.my_pod.mypod/net.robmunro.mypod.UpdateFeedsService: pid=17853 uid=10080 gids={3003, 1015}
I/ActivityThread(17853): Pub org.my_pod.mypod: net.robmunro.mypod.util.MyPodContentProvider
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +297ms
W/KeyCharacterMap(17822): No keyboard for id 131074
W/KeyCharacterMap(17822): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
D/MP3Player(17822): Stop the background Service
D/WifiLocator(17830): Too many cache misses. Need server request. hasLocation=0 noLocation=1 cacheMiss=2
E/GlsClient-query(17830): requestFailed
E/GlsClient-query(17830): ay.g
E/GlsClient-query(17830): at ay.d.t(Unknown Source)
E/GlsClient-query(17830): at ay.b.a(Unknown Source)
E/GlsClient-query(17830): at Z.b.g(Unknown Source)
E/GlsClient-query(17830): at Z.a.g(Unknown Source)
E/GlsClient-query(17830): at Z.d.run(Unknown Source)
E/GlsClient-query(17830): at aE.d.run(Unknown Source)
D/dalvikvm(13124): GC_EXPLICIT freed 2K, 50% free 2715K/5379K, external 1625K/2137K, paused 56ms
D/dalvikvm( 192): GC_EXPLICIT freed 88K, 44% free 4690K/8327K, external 16026K/17649K, paused 85ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +305ms
D/MP3Player(17822): Stop the background Service
D/dalvikvm(17830): GC_CONCURRENT freed 1201K, 51% free 3612K/7239K, external 1625K/2137K, paused 3ms+3ms
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/System.out(17830): [INFO:50519]: f: Response [http=200,length=147]
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +307ms
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +255ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +302ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +296ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +294ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
E/(Messenger)messenger: (17822): NullPointerException
W/System.err(17822): java.lang.NullPointerException
W/System.err(17822): at com.marie.mp3player.BackgroundService$ServiceWorker.run(BackgroundService.java:65)
W/System.err(17822): at java.lang.Thread.run(Thread.java:1019)
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +278ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
E/(Messenger)messenger: (17822): NullPointerException
W/System.err(17822): java.lang.NullPointerException
W/System.err(17822): at com.marie.mp3player.BackgroundService$ServiceWorker.run(BackgroundService.java:65)
W/System.err(17822): at java.lang.Thread.run(Thread.java:1019)
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +282ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +307ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +284ms
D/MP3Player(17822): Stop the background Service
I/ActivityManager( 96): Starting: Intent { cmp=com.marie.mp3player/.PlayAudio (has extras) } from pid 17822
I/handleMessge(17822): songNum: 10
I/ActivityManager( 96): Displayed com.marie.mp3player/.PlayAudio: +291ms
It was suggested that I add the code where the NullPointerException occurs. Very important. In fact here's the whole thread where the exception occurs marked with an arrow and stars:
/*
* This is the ServiceWorker thread that calls messenger to pass messages
* and data to the PlayAudio activity.
*/
class ServiceWorker implements Runnable
{
public void run() {
// do background processing here... a simple message for now
// send a message to the handler defined in the PlayAudio
try {
Message msg1 = Message.obtain();
msg1.obj = "Song";
msg1.arg1 = song;
if (messenger == null) Log.e("(Messenger)messenger: ", "NullPointerException");
messenger.send(msg1); // <== *** EXCEPTION OCCURS HERE ***
} catch (RemoteException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
// stop the service when done...
// BackgroundService.this.stopSelf();
// Or use the unbindBtn in the MP3Player activity.
}
}
If anyone sees a mistake here that would sometimes cause my Message instance to be null I sure would appreciate an answer.
Marie, assuming that the rest of your service is as in your other question. Here is what happens and causes your NPE.
In onCreate you create and start your thread, but you extract messenger in onStart method. If your worker method executes before onStart, you get NPE. The order of them is random, so sometimes you get NPE and sometimes not.

Categories

Resources