I have been trying to detect when the user launches an application on his/her device.
So I found this solution:
https://stackoverflow.com/a/7239840/833219
I added this code inside of a thread. So my application get the log every 3 milliseconds, but I cannot find the difference between logs, so I cannot detect what code is meant for the user's app launching.
Here is an example of the log I got when I add this line:
String w = log.toString();
Log.i("LockService","w ="+w);
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc android.process.media for broadcast com.android.providers.media/.UsbReceiver: pid=375 uid=10013 gids={1015, 1023, 1024, 2001, 3003, 3007}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.inputmethod.latin.dictionarypack for content provider com.google.android.inputmethod.latin.dictionarypack/.DictionaryProvider: pid=407 uid=10043 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc android.process.acore for content provider com.android.providers.userdictionary/.UserDictionaryProvider: pid=421 uid=10002 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): W/ActivityManager( 142): Unable to start service Intent { act=com.android.internal.telephony.IWapPushManager }: not found
06-04 00:20:14.765: I/LockService(854): W/ActivityManager( 142): Unable to start service Intent { act=com.android.ussd.IExtendedNetworkService }: not found
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.android.settings for broadcast com.android.settings/.widget.SettingsAppWidgetProvider: pid=476 uid=1000 gids={1015, 3002, 3001, 3003, 3007}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.android.contacts for broadcast com.android.contacts/.calllog.CallLogReceiver: pid=505 uid=10002 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.android.providers.calendar for broadcast com.android.providers.calendar/.CalendarReceiver: pid=545 uid=10007 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Config changed: {1.0 605mcc1mnc fr_FR layoutdir=0 sw320dp w320dp h508dp nrml long port finger -keyb/v/h -nav/h s.4}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.deskclock for broadcast com.google.android.deskclock/com.android.deskclock.AlarmInitReceiver: pid=562 uid=10012 gids={}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.email for broadcast com.google.android.email/com.android.email.service.EmailBroadcastReceiver: pid=577 uid=10014 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.exchange for service com.google.android.exchange/com.android.exchange.ExchangeService: pid=596 uid=10025 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.apps.genie.geniewidget for broadcast com.google.android.apps.genie.geniewidge
06-04 00:20:15.082: I/LockService(854): w =--------- beginning of /dev/log/system
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Memory class: 48
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Config changed: {1.0 0mcc0mnc fr_FR layoutdir=0 sw320dp w320dp h508dp nrml long port ?uimode ?night finger -keyb/v/h -nav/h s.2}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): System now ready
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.systemui for service com.android.systemui/.SystemUIService: pid=210 uid=1000 gids={1015, 3002, 3001, 3003, 3007}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.gsf.login for service com.google.android.gsf.login/com.google.android.gsf.loginservice.GoogleLoginService: pid=238 uid=10018 gids={3003, 1015, 1007, 2001, 3006}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.google.process.gapps for content provider com.google.android.gsf/.gservices.GservicesProvider: pid=262 uid=10018 gids={3003, 1015, 1007, 2001, 3006}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Config changed: {1.0 0mcc0mnc fr_FR layoutdir=0 sw320dp w320dp h508dp nrml long port finger -keyb/v/h -nav/h s.3}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.wallpaper for service com.android.wallpaper/.nexus.NexusWallpaper: pid=289 uid=10027 gids={1006}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.inputmethod.latin for service com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME: pid=301 uid=10024 gids={}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.phone for added application com.android.phone: pid=316 uid=1001 gids={3002, 3001, 3003, 1015}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.nfc for added application com.android.nfc: pid=331 uid=1027 gids={3002, 3001}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.android.launcher/com.android.launcher2.Launcher} from pid 0
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=354 uid=10026 gids={}
Using this code, how can I detect that the user launched an application?
Reading the logs is a horrible idea, and also broken across versions of the system. There is actually a broadcast intent for which you can register here: ACTION_PACKAGE_FIRST_LAUNCH, however, take note that this is only available in API level 12+.
you can detect application launch with tag of ActivityManager in logs.
in log you can find useful data.you can detect run packages.
for example :
06-06 16:09:06.007: I/ActivityManager(1663): Starting: Intent { act=android.intent.action.MAIN flg=0x10840000 cmp=com.android.phone/.InCallScreen } from pid -1
it is com.android.phone package and InCallScreen starts for first page.
you can check packages name and detect when your target application launched.
Related
I have an app that registers a BroadcastReceiver in the manifest
<receiver
android:name=".smsprocessing.SmsBroadcastReceiver"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.provider.Telephony.SMS_DELIVER" />
<action android:name="android.provider.Telephony.SMS_DELIVER_ACTION" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
It has always been working perfectly fine when I'm testing it, but today I tried sending an SMS to a phone with the app installed which I hadn't touched for a few hours. The app has been working fine on this phone before while testing, but I've always tested it with the display on or within a few minutes after locking the screen.
It seems that my BroadcastReceiver wasn't triggered today when I hadn't used the phone for a few hours. The SMS was received and triggered the stock Messaging app, but my BroadcastReceiver was not triggered (or at least, the foreground service I'm starting from onReceive() wasn't started).
The phone in question is a Motorola Moto G running Android 4.4.4.
EDIT
When I connect the phone via USB minutes after it was supposed to have triggered the BroadcastReceiver, I see only two logs related to my app:
10-12 22:33:28.438 1039-1053/? I/ActivityManager: Start proc com.example.myapp for broadcast com.example.myapp/com.example.myapp.smsprocessing.SmsBroadcastReceiver: pid=3554 uid=10230 gids={50230, 3003}
10-12 22:33:28.961 1039-4323/? I/ActivityManager: Process com.example.myapp (pid 3554) has died.
Here is the full log from when (I think) the SMS was received (I have prefixed the above two lines with ###):
10-12 22:33:28.235 1039-1186/? I/PackageManager: Adding preferred activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity} for user 0 :
10-12 22:33:28.271 1039-4323/? I/PackageManager: Adding preferred activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity} for user 0 :
10-12 22:33:28.291 1039-1401/? I/PackageManager: Adding preferred activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity} for user 0 :
10-12 22:33:28.312 1039-1100/? I/PackageManager: Adding preferred activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity} for user 0 :
10-12 22:33:28.345 1039-1053/? I/ActivityManager: Start proc com.android.mms for broadcast com.android.mms/.transaction.PrivilegedSmsReceiver: pid=3524 uid=10030 gids={50030, 3003, 1028, 1015}10-12 22:33:28.345 1039-1053/? I/ActivityManager: Start proc com.android.mms for broadcast com.android.mms/.transaction.PrivilegedSmsReceiver: pid=3524 uid=10030 gids={50030, 3003, 1028, 1015}
### 10-12 22:33:28.438 1039-1053/? I/ActivityManager: Start proc com.example.myapp for broadcast com.example.myapp/com.example.myapp.smsprocessing.SmsBroadcastReceiver: pid=3554 uid=10230 gids={50230, 3003}
10-12 22:33:28.635 1039-1093/? D/WifiService: Client connection lost with reason: 4
10-12 22:33:28.644 1039-1050/? I/ActivityManager: Start proc android.process.acore for content provider com.android.providers.contacts/.ContactsProvider2: pid=3571 uid=10010 gids={50010, 3003, 1028, 1015, 1023}
10-12 22:33:28.645 1039-4321/? I/ActivityManager: Process com.google.android.gms (pid 2593) has died.
10-12 22:33:28.648 1039-4321/? W/ActivityManager: Service ServiceRecord{43d5d0e0 u0 com.google.android.gms/.chimera.GmsApiService} in process ProcessRecord{425f9028 2593:com.google.android.gms/u0a22} not same as in map: null
10-12 22:33:28.649 1039-4321/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/.chimera.GmsIntentOperationService in 26259ms
Scheduling restart of crashed service com.google.android.gms/.checkin.CheckinService in 26259ms
Service ServiceRecord{43116f88 u0 com.google.android.gms/.chimera.GmsBoundBrokerService} in process ProcessRecord{425f9028 2593:com.google.android.gms/u0a22} not same as in map: null
10-12 22:33:28.848 1039-1290/? I/ActivityManager: Start proc com.google.android.gms for service com.google.android.gms/.ads.identifier.service.AdvertisingIdService: pid=3618 uid=10022 gids={50022, 3003, 1007, 1028, 1015, 3002, 3001, 3007, 2001, 3006}
### 10-12 22:33:28.961 1039-4323/? I/ActivityManager: Process com.example.myapp (pid 3554) has died.
10-12 22:33:29.279 1039-1313/? I/ActivityManager: Process com.google.android.apps.photos (pid 3476) has died.
10-12 22:33:29.998 1039-1049/? I/ActivityManager: Process com.google.android.gms.unstable (pid 3285) has died.
10-12 22:33:30.227 1039-1093/? D/WifiService: New client listening to asynchronous messages
10-12 22:33:30.422 263-349/? W/Vold: Returning OperationFailed - no handler for errno 30
10-12 22:33:30.425 263-349/? W/Vold: Returning OperationFailed - no handler for errno 30
10-12 22:33:30.483 1039-1100/? I/ActivityManager: Start proc com.google.android.gms.unstable for service com.google.android.gms/.droidguard.DroidGuardService: pid=3693 uid=10022 gids={50022, 3003, 1007, 1028, 1015, 3002, 3001, 3007, 2001, 3006}
10-12 22:33:30.847 1039-4323/? I/ActivityManager: Process android.process.acore (pid 3571) has died.
10-12 22:33:31.308 1039-3556/? I/ActivityManager: Process com.android.mms (pid 3524) has died.
I have a question: is there somebody that use MVVMCross 3.5.1 with Api level android 21 and xamarin studio 5.9.3? I have a problem: I reference mvvmcross in an android app. I have a splashscreen and a firstview. When I tried to start with emulator I don't have any problem with level 15 emulator but when I tried it with the last version (Api 21) the app after splashscreen is closed without any error (not open the firstview).
Is there a solution?
UPDATE
I tried with logcat. In the following I attached the log:
W/AudioTrack( 394): AUDIO_OUTPUT_FLAG_FAST denied by client
I/ActivityManager( 394): START u0 {act=android.intent.action.MAIN cat=[android.
intent.category.LAUNCHER] flg=0x10000000 cmp=com.nowhere.nowhere/md51f5aeae0dbe3
fa3acab67292d41114d1.SplashScreen (has extras)} from uid 10007 on display 0
I/Choreographer( 824): Skipped 67 frames! The application may be doing too muc
h work on its main thread.
I/art ( 1716): Not late-enabling -Xcheck:jni (already on)
I/ActivityManager( 394): Start proc com.nowhere.nowhere for activity com.nowher
e.nowhere/md51f5aeae0dbe3fa3acab67292d41114d1.SplashScreen: pid=1716 uid=10056 g
ids={50056, 9997, 3003} abi=armeabi-v7a
I/Choreographer( 394): Skipped 32 frames! The application may be doing too muc
h work on its main thread.
F/MonoDroid( 1716): shared runtime initialization error: dlopen failed: library
"/data/app/Mono.Android.DebugRuntime-1/lib/arm/lib/libmonosgen-2.0.so" not found
I/Zygote ( 66): Process 1716 exited cleanly (1)
I/ActivityManager( 394): Process com.nowhere.nowhere (pid 1716) has died
I/art ( 1731): Not late-enabling -Xcheck:jni (already on)
I/ActivityManager( 394): Start proc com.nowhere.nowhere for activity com.nowher
e.nowhere/md51f5aeae0dbe3fa3acab67292d41114d1.SplashScreen: pid=1731 uid=10056 g
ids={50056, 9997, 3003} abi=armeabi-v7a
F/MonoDroid( 1731): shared runtime initialization error: dlopen failed: library
"/data/app/Mono.Android.DebugRuntime-1/lib/arm/lib/libmonosgen-2.0.so" not found
I/Zygote ( 66): Process 1731 exited cleanly (1)
I/ActivityManager( 394): Process com.nowhere.nowhere (pid 1731) has died
I/art ( 1746): Not late-enabling -Xcheck:jni (already on)
I/ActivityManager( 394): Start proc com.nowhere.nowhere for activity com.nowher
e.nowhere/md51f5aeae0dbe3fa3acab67292d41114d1.SplashScreen: pid=1746 uid=10056 g
ids={50056, 9997, 3003} abi=armeabi-v7a
F/MonoDroid( 1746): shared runtime initialization error: dlopen failed: library
"/data/app/Mono.Android.DebugRuntime-1/lib/arm/lib/libmonosgen-2.0.so" not found
I/Zygote ( 66): Process 1746 exited cleanly (1)
I/ActivityManager( 394): Process com.nowhere.nowhere (pid 1746) has died
W/ActivityManager( 394): Force removing ActivityRecord{27f513c9 u0 com.nowhere.
nowhere/md51f5aeae0dbe3fa3acab67292d41114d1.SplashScreen t8}: app died, no saved
state
W/WindowManager( 394): Failed looking up window
W/WindowManager( 394): java.lang.IllegalArgumentException: Requested window and
roid.view.ViewRootImpl$W#3c7a1def does not exist
W/WindowManager( 394): at com.android.server.wm.WindowManagerService.wi
ndowForClientLocked(WindowManagerService.java:8412)
W/WindowManager( 394): at com.android.server.wm.WindowManagerService.wi
ndowForClientLocked(WindowManagerService.java:8403)
W/WindowManager( 394): at com.android.server.wm.WindowManagerService.re
moveWindow(WindowManagerService.java:2558)
W/WindowManager( 394): at com.android.server.wm.Session.remove(Session.
java:186)
W/WindowManager( 394): at android.view.ViewRootImpl.dispatchDetachedFro
mWindow(ViewRootImpl.java:2920)
W/WindowManager( 394): at android.view.ViewRootImpl.doDie(ViewRootImpl.
java:5390)
W/WindowManager( 394): at android.view.ViewRootImpl$ViewRootHandler.han
dleMessage(ViewRootImpl.java:3223)
W/WindowManager( 394): at android.os.Handler.dispatchMessage(Handler.ja
va:102)
W/WindowManager( 394): at android.os.Looper.loop(Looper.java:135)
W/WindowManager( 394): at android.os.HandlerThread.run(HandlerThread.ja
va:61)
W/WindowManager( 394): at com.android.server.ServiceThread.run(ServiceT
hread.java:46)
W/InputMethodManagerService( 394): Window already focused, ignoring focus gain
of: com.android.internal.view.IInputMethodClient$Stub$Proxy#14f4aa0b attribute=n
ull, token = android.os.BinderProxy#5c9e508
I/Choreographer( 824): Skipped 56 frames! The application may be doing too muc
h work on its main thread.
D/TaskPersister( 394): removeObsoleteFile: deleting file=8_task.xml
UPDATE 2
The bind does not work. Inside the view..
UPDATE 3
I put the code in this repo:
https://onedrive.live.com/redir?resid=1E563B1D1AD8A1C!15847&authkey=!AII01sfuzToQiUQ&ithint=file%2czip
I used this configuration for the test:
1. Nexus 5,
2. Android 5.0-API Level 21,
3. CPU/ABI, I have chosen Google APIs Intel Atom(x86_64),
4. Use Host GPU.
UPDATE 4
new link for code: http://1drv.ms/1MZWf45
Thanks
Alessandro
I found the problem. The problem was the emulator. I tried to change the configuration and now run without problem.
Thanks
Al.
I have been confused by a random crash in my app since I updated to cordova 5 and started using crosswalk.
This is my logcat:
D/STATUSBAR-NetworkController( 1110): refreshSignalCluster - setNWBoosterIndicators(false)
D/STATUSBAR-NetworkController( 1110): refreshSignalCluster: data=-1 bt=false
D/STATUSBAR-IconMerger( 1110): checkOverflow(1344), More:false, Req:false Child:5
W/ActivityManager( 891): Permission Denial: getCurrentUser() from pid=32252, uid=10037 requires android.permission.INTERACT_ACROSS_USERS
I/ActivityManager( 891): Process com.tesingguru.tesing_Guru (pid 29852) (adj 0) has died.
I/WindowState( 891): WIN DEATH: Window{42fb82c0 u0 com.tesingguru.tesing_Guru/com.tesingguru.tesing_Guru.MainActivity}
I/SurfaceFlinger( 329): id=3847 Removed NainActivit (16/29)
I/SurfaceFlinger( 329): id=3847 Removed NainActivit (-2/29)
I/FactoryTest( 891): isRunningFactoryApp=false
I/FactoryTest( 891): isRunningFactoryApp=false
W/ActivityManager( 891): Force removing ActivityRecord{4303e860 u0 com.tesingguru.tesing_Guru/.MainActivity t221}: app died, no saved state
I am completely confused by this? The line I am suspecting is:
W/ActivityManager( 891): Permission Denial: getCurrentUser() from pid=32252, uid=10037 requires android.permission.
I have a viewer application, implement with ImageView and ViewPager from Android Compatibility Package. For each page, I render some Bitmap and put them into ViewPager. It works fine, but sometimes the application just crashed without exception nor register dump. I noticed that, normally, the application didn't crash, just log many GC messages. But when system ActivityManager start to schedule restart some background system Service, the application get a big chance to crash when switching between pages.
I searched some questions, but they are about Service being killed because of low memory, restart failed because of state inconsistency, or something. But in my case, It's foreground Activity being killed, just because some system Services were scheduled restart. How could a foreground Activity being killed "by background Service"?
Although in log, the Services seem to restart failed because of low memory, but my Activity just being killed without OutOfMemoryError. I can't figure out what is the real problem caused my application being killed...
PS. If I don't switch between pages, the application lives, but system is scheduling restart Services repeatedly. In this situation, the application is easy to crash when switching between pages.
PS2. device is: ASUS Transformer TF101, Android 3.2, Kernel version: 2.6.36.3-00003-g9baf8f7
Here is the log, mycompany.viewer.MagazineActivity is the main Activity:
10-21 15:18:47.260: INFO/ActivityManager(135): Process com.google.android.apps.maps:NetworkLocationService (pid 14583) has died.
10-21 15:18:47.260: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.apps.maps/com.google.android.location.internal.server.NetworkLocationService in 56367ms
10-21 15:18:47.260: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:47.360: INFO/ActivityManager(135): Process com.google.android.music (pid 14500) has died.
10-21 15:18:47.360: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.music/.dl.DownloadManager$DownloadManagerService in 66267ms
10-21 15:18:47.360: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:47.560: INFO/ActivityManager(135): Process android.process.media (pid 14482) has died.
10-21 15:18:47.560: WARN/ActivityManager(135): Scheduling restart of crashed service com.android.providers.media/.MtpService in 76067ms
10-21 15:18:47.560: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:47.660: INFO/ActivityManager(135): Process net.smart.appstore.client (pid 14610) has died.
10-21 15:18:47.660: WARN/ActivityManager(135): Scheduling restart of crashed service net.smart.appstore.client/.service.LogSenderService in 85969ms
10-21 15:18:47.660: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:47.760: INFO/ActivityManager(135): Process com.asus.keyboard (pid 14617) has died.
10-21 15:18:47.760: WARN/ActivityManager(135): Scheduling restart of crashed service com.asus.keyboard/.KeyboardService in 95868ms
10-21 15:18:47.760: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:47.830: INFO/ActivityManager(135): Process com.asus.DLNA (pid 14634) has died.
10-21 15:18:47.830: WARN/ActivityManager(135): Scheduling restart of crashed service com.asus.DLNA/.MusicPlaybackService in 105803ms
10-21 15:18:47.830: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:48.230: DEBUG/dalvikvm(14526): GC_FOR_ALLOC freed 431K, 31% free 19826K/28615K, paused 23ms
10-21 15:18:52.480: DEBUG/dalvikvm(14526): GC_CONCURRENT freed 1293K, 29% free 20566K/28615K, paused 2ms+3ms
10-21 15:18:52.840: DEBUG/skia(14526): purging 213K from font cache [14 entries]
10-21 15:18:52.870: DEBUG/dalvikvm(14526): GC_EXPLICIT freed 378K, 30% free 20189K/28615K, paused 2ms+3ms
10-21 15:18:53.640: INFO/ActivityManager(135): Start proc com.asus.DLNA for service com.asus.DLNA/com.asus.DMS.DLNAServerService: pid=14642 uid=10054 gids={3003, 1015}
10-21 15:18:53.690: INFO/DMS(14642): ===========================> onCreate()
10-21 15:18:54.040: INFO/ActivityManager(135): Process com.asus.DLNA (pid 14642) has died.
10-21 15:18:54.040: WARN/ActivityManager(135): Scheduling restart of crashed service com.asus.DLNA/com.asus.DMS.DLNAServerService in 137364ms
10-21 15:18:54.040: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:54.770: INFO/ActivityManager(135): Process com.google.process.gapps (pid 25767) has died.
10-21 15:18:54.770: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.gsf/.gtalkservice.service.GTalkService in 108858ms
10-21 15:18:54.770: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.location/.NetworkLocationService in 118858ms
10-21 15:18:54.780: DEBUG/LocationProviderProxy(135): LocationProviderProxy.onServiceDisconnected ComponentInfo{com.google.android.location/com.google.android.location.NetworkLocationService}
10-21 15:18:54.780: DEBUG/GeocoderProxy(135): onServiceDisconnected ComponentInfo{com.google.android.location/com.google.android.location.NetworkLocationService}
10-21 15:18:54.780: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:55.430: ERROR/InputDispatcher(135): channel '4110db70 mycompany.viewer/mycompany.viewer.MagazineActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
10-21 15:18:55.430: ERROR/InputDispatcher(135): channel '4110db70 mycompany.viewer/mycompany.viewer.MagazineActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-21 15:18:55.430: INFO/ActivityManager(135): Process mycompany.viewer (pid 14526) has died.
10-21 15:18:55.440: INFO/WindowManager(135): WIN DEATH: Window{4110db70 mycompany.viewer/mycompany.viewer.MagazineActivity paused=false}
10-21 15:18:55.440: INFO/WindowManager(135): WINDOW DIED Window{4110db70 mycompany.viewer/mycompany.viewer.MagazineActivity paused=false}
10-21 15:18:55.470: INFO/ActivityManager(135): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=14649 uid=10037 gids={}
10-21 15:18:55.470: INFO/ActivityManager(135): Low Memory: No more background processes.
10-21 15:18:55.660: DEBUG/dalvikvm(135): GC_EXPLICIT freed 875K, 22% free 26097K/33415K, paused 29ms+15ms
10-21 15:18:55.670: DEBUG/WindowManager(135): adjustConfigurationLw, config:{1.0 0mcc0mnc (no locale) sw800dp w1280dp h752dp xlrg land ?uimode ?night finger -keyb/v/h -nav/v} mLidOpen:-1 mHasDockFeature:true mHasHallSensorFeature:true config.hardKeyboardHidden:2
10-21 15:18:55.710: INFO/ActivityThread(14649): Pub com.android.launcher2.settings: com.android.launcher2.LauncherProvider
10-21 15:18:56.250: DEBUG/dalvikvm(14649): GC_FOR_ALLOC freed 132K, 4% free 6513K/6727K, paused 34ms
10-21 15:18:56.350: DEBUG/dalvikvm(14649): GC_CONCURRENT freed 40K, 2% free 6953K/7047K, paused 2ms+2ms
10-21 15:18:56.870: INFO/ActivityManager(135): Start proc com.asus.mygazine for broadcast com.asus.mygazine/.UtilsReceiver: pid=14659 uid=10027 gids={1015}
10-21 15:18:56.910: DEBUG/TabletStatusBar(186): lights on
10-21 15:18:56.940: DEBUG/dalvikvm(14649): GC_CONCURRENT freed 197K, 4% free 7231K/7495K, paused 6ms+2ms
10-21 15:18:56.960: DEBUG/dalvikvm(87): GC_EXPLICIT freed 11K, 5% free 6298K/6595K, paused 3ms+2ms
10-21 15:18:56.980: DEBUG/libEGL(14649): loaded /system/lib/egl/libGLES_android.so
10-21 15:18:57.000: DEBUG/dalvikvm(87): GC_EXPLICIT freed <1K, 5% free 6298K/6595K, paused 2ms+2ms
10-21 15:18:57.030: DEBUG/dalvikvm(87): GC_EXPLICIT freed <1K, 5% free 6298K/6595K, paused 2ms+3ms
10-21 15:18:57.060: DEBUG/libEGL(14649): loaded /system/lib/egl/libEGL_tegra.so
10-21 15:18:57.160: DEBUG/libEGL(14649): loaded /system/lib/egl/libGLESv1_CM_tegra.so
10-21 15:18:57.190: DEBUG/libEGL(14649): loaded /system/lib/egl/libGLESv2_tegra.so
10-21 15:18:57.240: DEBUG/OpenGLRenderer(14649): Creating OpenGL renderer caches
10-21 15:18:57.250: DEBUG/OpenGLRenderer(14649): Enabling debug mode 0
10-21 15:18:57.250: DEBUG/OpenGLRenderer(14649): Layers will be composited as regions
10-21 15:18:57.250: DEBUG/dalvikvm(14649): GC_CONCURRENT freed 252K, 5% free 7430K/7815K, paused 3ms+2ms
10-21 15:18:57.260: INFO/TextType(212): TextType = 0x0
10-21 15:18:57.260: WARN/InputManagerService(135): Got RemoteException sending setActive(false) notification to pid 14526 uid 10065
PS3. some other log to describe the crash progress
After crash, those background services can start:
10-24 14:06:00.099: INFO/ActivityManager(135): Start proc com.asus.DLNA for service com.asus.DLNA/com.asus.DMS.DLNAServerService: pid=6482 uid=10054 gids={3003, 1015}
10-24 14:06:44.319: INFO/ActivityManager(135): Start proc com.android.bluetooth for service com.android.bluetooth/.pbap.BluetoothPbapService: pid=6495 uid=10061 gids={3003, 3002, 3001, 1015}
10-24 14:06:44.359: INFO/ActivityThread(6495): Pub com.android.bluetooth.opp: com.android.bluetooth.opp.BluetoothOppProvider
10-24 14:07:04.319: INFO/ActivityManager(135): Start proc com.rechild.advancedtaskkiller for service com.rechild.advancedtaskkiller/.BackService: pid=6502 uid=10077 gids={1007, 3003, 1015}
10-24 14:07:14.849: INFO/ActivityManager(135): Start proc android.process.acore for content provider com.android.providers.contacts/.ContactsProvider2: pid=6512 uid=10009 gids={3003, 1015}
10-24 14:07:14.889: INFO/ActivityThread(6512): Pub user_dictionary: com.android.providers.userdictionary.UserDictionaryProvider
10-24 14:07:14.899: INFO/ActivityThread(6512): Pub com.android.social: com.android.providers.contacts.SocialProvider
10-24 14:07:14.919: INFO/ActivityThread(6512): Pub applications: com.android.providers.applications.ApplicationsProvider
10-24 14:07:14.949: INFO/ActivityThread(6512): Pub contacts;com.android.contacts: com.android.providers.contacts.ContactsProvider2
10-24 14:07:14.959: INFO/ActivityThread(6512): Pub call_log: com.android.providers.contacts.CallLogProvider
Open the viewer again, load some pages, background services begin to die,
10-24 14:08:22.269: INFO/ActivityManager(135): Process android.process.media (pid 6422) has died.
10-24 14:08:22.329: INFO/ActivityManager(135): Process com.asus.mygazine (pid 6385) has died.
10-24 14:08:22.429: INFO/ActivityManager(135): Process com.google.android.apps.maps:FriendService (pid 6460) has died.
10-24 14:08:22.529: INFO/ActivityManager(135): Process android.process.acore (pid 6512) has died.
10-24 14:08:22.539: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:08:33.839: INFO/ActivityManager(135): Process com.android.launcher (pid 6375) has died.
10-24 14:08:33.839: INFO/WindowManager(135): WIN DEATH: Window{40e07160 com.android.launcher/com.android.launcher2.Launcher paused=false}
10-24 14:08:33.839: INFO/ActivityManager(135): Low Memory: No more background processes.
and scheduling restart.
10-24 14:08:51.279: INFO/ActivityManager(135): Process com.google.android.music (pid 6398) has died.
10-24 14:08:51.279: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.music/.dl.DownloadManager$DownloadManagerService in 5000ms
10-24 14:08:51.279: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:08:51.369: INFO/ActivityManager(135): Process com.google.android.apps.maps:NetworkLocationService (pid 6452) has died.
10-24 14:08:51.369: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.apps.maps/com.google.android.location.internal.server.NetworkLocationService in 14904ms
10-24 14:08:51.369: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:08:51.469: INFO/ActivityManager(135): Process com.android.bluetooth (pid 6495) has died.
10-24 14:08:51.469: WARN/ActivityManager(135): Scheduling restart of crashed service com.android.bluetooth/.pbap.BluetoothPbapService in 24806ms
10-24 14:08:51.469: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:08:51.569: INFO/ActivityManager(135): Process com.asus.DLNA (pid 6482) has died.
10-24 14:08:51.569: WARN/ActivityManager(135): Scheduling restart of crashed service com.asus.DLNA/.MusicPlaybackService in 34707ms
10-24 14:08:51.569: WARN/ActivityManager(135): Scheduling restart of crashed service com.asus.DLNA/com.asus.DMS.DLNAServerService in 44707ms
10-24 14:08:51.569: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:08:51.669: INFO/ActivityManager(135): Process com.rechild.advancedtaskkiller (pid 6502) has died.
10-24 14:08:51.669: WARN/ActivityManager(135): Scheduling restart of crashed service com.rechild.advancedtaskkiller/.BackService in 54607ms
10-24 14:08:51.669: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:08:56.299: INFO/ActivityManager(135): Start proc com.google.android.music for service com.google.android.music/.dl.DownloadManager$DownloadManagerService: pid=6528 uid=10029 gids={3003, 1015}
10-24 14:08:56.409: INFO/ActivityThread(6528): Pub com.google.android.music.MusicContent: com.google.android.music.store.MusicContentProvider
10-24 14:08:56.439: INFO/MusicStore(6528): Database version: 31
10-24 14:08:56.439: WARN/AndroidMusic(6528): Need to wait for MusicPreferences to be created
10-24 14:08:56.639: WARN/AndroidMusic(6528): MusicPreferences still not made, creating on UI thread
Sometimes, some of them would start successfully.
10-24 14:09:16.299: INFO/ActivityManager(135): Start proc com.android.bluetooth for service com.android.bluetooth/.pbap.BluetoothPbapService: pid=6580 uid=10061 gids={3003, 3002, 3001, 1015}
10-24 14:09:16.329: INFO/ActivityThread(6580): Pub com.android.bluetooth.opp: com.android.bluetooth.opp.BluetoothOppProvider
10-24 14:09:26.309: INFO/ActivityManager(135): Start proc com.asus.DLNA for service com.asus.DLNA/.MusicPlaybackService: pid=6588 uid=10054 gids={3003, 1015}
10-24 14:09:36.289: INFO/DMS(6588): ===========================> onCreate()
10-24 14:09:46.299: INFO/ActivityManager(135): Start proc com.rechild.advancedtaskkiller for service com.rechild.advancedtaskkiller/.BackService: pid=6595 uid=10077 gids={1007, 3003, 1015}
10-24 14:09:56.299: INFO/ActivityManager(135): Start proc com.google.android.music for service com.google.android.music/.dl.DownloadManager$DownloadManagerService: pid=6602 uid=10029 gids={3003, 1015}
10-24 14:09:56.419: INFO/ActivityThread(6602): Pub com.google.android.music.MusicContent: com.google.android.music.store.MusicContentProvider
10-24 14:09:56.439: DEBUG/dalvikvm(6602): GC_CONCURRENT freed 165K, 4% free 6637K/6855K, paused 2ms+2ms
10-24 14:09:56.449: INFO/MusicStore(6602): Database version: 31
10-24 14:09:56.459: WARN/AndroidMusic(6602): Need to wait for MusicPreferences to be created
10-24 14:09:56.659: WARN/AndroidMusic(6602): MusicPreferences still not made, creating on UI thread
10-24 14:09:56.699: DEBUG/MusicPreferences(6602): New Active account: null
10-24 14:09:56.709: INFO/ActivityManager(135): Start proc android.process.media for content provider com.android.providers.media/.MediaProvider: pid=6616 uid=10031 gids={1015, 1023, 1024, 2001, 3003}
10-24 14:09:56.719: DEBUG/MusicStore(6602): Disabled WAL
10-24 14:09:56.719: DEBUG/MusicStore(6602): Database opened
10-24 14:09:56.739: INFO/ActivityThread(6616): Pub media: com.android.providers.media.MediaProvider
10-24 14:09:56.739: INFO/ActivityManager(135): Process com.google.android.apps.maps:NetworkLocationService (pid 6558) has died.
10-24 14:09:56.749: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.apps.maps/com.google.android.location.internal.server.NetworkLocationService in 5000ms
10-24 14:09:56.749: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:09:57.099: INFO/MediaProvider(6616): Update ID=1, mount=/system, isMounted=1, VID = -1
10-24 14:09:57.139: INFO/MediaProvider(6616): Update ID=2, mount=/data, isMounted=1, VID = -1
10-24 14:09:57.509: INFO/MediaProvider(6616): Update ID=1, mount=/mnt/sdcard, isMounted=1, VID = -1
10-24 14:09:57.529: INFO/ActivityThread(6616): Pub downloads: com.android.providers.downloads.DownloadProvider
10-24 14:09:57.539: INFO/ActivityThread(6616): Pub drm: com.android.providers.drm.DrmProvider
Then the system begins to scheduling restart, success some, failed some, repeatedly. Btw, com.google.android.music/.dl.DownloadManager$DownloadManagerService and com.google.android.apps.maps/com.google.android.location.internal.server.NetworkLocationService always failed to restart.
Log looks like mix of "Scheduling restart...", "Start proc...", "GC ..."
If I switch between pages, more Services are killed, system still scheduling restart repeatedly.
10-24 14:11:04.619: INFO/ActivityManager(135): Process com.android.bluetooth (pid 6763) has died.
10-24 14:11:04.619: WARN/ActivityManager(135): Scheduling restart of crashed service com.android.bluetooth/.pbap.BluetoothPbapService in 77800ms
10-24 14:11:04.619: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:11:04.729: INFO/ActivityManager(135): Process com.asus.DLNA (pid 6588) has died.
10-24 14:11:04.729: WARN/ActivityManager(135): Scheduling restart of crashed service com.asus.DLNA/com.asus.DMS.DLNAServerService in 22273ms
10-24 14:11:04.729: WARN/ActivityManager(135): Scheduling restart of crashed service com.asus.DLNA/.MusicPlaybackService in 32273ms
10-24 14:11:04.729: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:11:04.849: INFO/ActivityManager(135): Process com.rechild.advancedtaskkiller (pid 6595) has died.
10-24 14:11:04.849: WARN/ActivityManager(135): Scheduling restart of crashed service com.rechild.advancedtaskkiller/.BackService in 42147ms
10-24 14:11:04.849: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:11:05.959: INFO/ActivityManager(135): Process com.google.process.gapps (pid 6410) has died.
10-24 14:11:05.959: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.gsf/.gtalkservice.service.GTalkService in 51042ms
10-24 14:11:05.959: DEBUG/LocationProviderProxy(135): LocationProviderProxy.onServiceDisconnected ComponentInfo{com.google.android.location/com.google.android.location.NetworkLocationService}
10-24 14:11:05.959: DEBUG/GeocoderProxy(135): onServiceDisconnected ComponentInfo{com.google.android.location/com.google.android.location.NetworkLocationService}
10-24 14:11:05.959: WARN/ActivityManager(135): Scheduling restart of crashed service com.google.android.location/.NetworkLocationService in 61042ms
10-24 14:11:05.959: INFO/ActivityManager(135): Low Memory: No more background processes.
10-24 14:11:06.079: DEBUG/dalvikvm(6438): GC_FOR_ALLOC freed 431K, 27% free 21267K/28871K, paused 23ms
10-24 14:11:07.009: INFO/ActivityManager(135): Start proc com.google.android.music for service com.google.android.music/.dl.DownloadManager$DownloadManagerService: pid=6771 uid=10029 gids={3003, 1015}
10-24 14:11:07.129: INFO/ActivityThread(6771): Pub com.google.android.music.MusicContent: com.google.android.music.store.MusicContentProvider
10-24 14:11:07.149: DEBUG/dalvikvm(6771): GC_CONCURRENT freed 145K, 2% free 6739K/6855K, paused 8ms+2ms
10-24 14:11:07.149: INFO/MusicStore(6771): Database version: 31
10-24 14:11:07.159: WARN/AndroidMusic(6771): Need to wait for MusicPreferences to be created
10-24 14:11:07.229: DEBUG/dalvikvm(6438): GC_CONCURRENT freed 1293K, 24% free 22006K/28871K, paused 2ms+4ms
10-24 14:11:07.359: WARN/AndroidMusic(6771): MusicPreferences still not made, creating on UI thread
10-24 14:11:07.369: INFO/ActivityManager(135): Start proc com.google.process.gapps for content provider com.google.android.gsf/.gservices.GservicesProvider: pid=6783 uid=10025 gids={3003, 1015, 2001, 1007}
10-24 14:11:07.419: INFO/ActivityThread(6783): Pub com.google.settings: com.google.android.gsf.settings.GoogleSettingsProvider
10-24 14:11:07.419: INFO/ActivityThread(6783): Pub subscribedfeeds: com.google.android.gsf.subscribedfeeds.SubscribedFeedsProvider
10-24 14:11:07.439: INFO/ActivityThread(6783): Pub com.google.contacts.gal.provider: com.google.android.syncadapters.contacts.GalProvider
10-24 14:11:07.449: INFO/ActivityThread(6783): Pub com.google.android.gsf.gservices: com.google.android.gsf.gservices.GservicesProvider
10-24 14:11:07.449: INFO/GservicesProvider(6783): Gservices pushing to system: true; secure: true
10-24 14:11:07.449: INFO/ActivityThread(6783): Pub com.google.android.providers.talk: com.google.android.gsf.talk.TalkProvider
Switching some more pages, finally, the application crashed, as the top most log.
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.