[android-developers] HELP: Receiver killed on startup.

2010-12-29 Thread Raj
Experts,

I have a simple receiver that listens to the BOOT_COMPLETED
action. The manifest is as follows

--
?xml version=1.0 encoding=utf-8?
manifest xmlns:android=http://schemas.android.com/apk/res/android;
  package=com.preciseinc.DroidLocator
  android:versionCode=1
  android:versionName=1.0
uses-permission
android:name=android.permission.RECEIVE_BOOT_COMPLETED /
uses-permission android:name=android.permission.INTERNET /
uses-permission
android:name=android.permission.ACCESS_FINE_LOCATION /
uses-permission
android:name=android.permission.ACCESS_NETWORK_STATE /
uses-sdk android:minSdkVersion=8 /

application android:icon=@drawable/icon android:label=@string/
app_name android:debuggable=true
receiver android:name=ServiceAutoStarter
android:process=:DroidLocator
intent-filter
action
android:name=android.intent.action.BOOT_COMPLETED/
/intent-filter
/receiver
/application
/manifest
--

However, when I start debugging with an emulator, the apk gets
installed, but the receiver process is terminated. Please see a
snippet of the logcat below.

--
12-29 13:55:48.674: DEBUG/PackageManager(60): Scanning package
com.preciseinc.DroidLocator
12-29 13:55:48.684: INFO/PackageManager(60): Package
com.preciseinc.DroidLocator codePath changed from /data/app/
com.preciseinc.DroidLocator-1.apk to /data/app/
com.preciseinc.DroidLocator-2.apk; Retaining data and using new
12-29 13:55:48.694: INFO/PackageManager(60): /data/app/
com.preciseinc.DroidLocator-2.apk changed; unpacking
12-29 13:55:48.704: DEBUG/installd(35): DexInv: --- BEGIN '/data/app/
com.preciseinc.DroidLocator-2.apk' ---
12-29 13:55:48.934: DEBUG/dalvikvm(363): DexOpt: load 47ms, verify
29ms, opt 2ms
12-29 13:55:48.954: DEBUG/installd(35): DexInv: --- END '/data/app/
com.preciseinc.DroidLocator-2.apk' (success) ---
12-29 13:55:48.954: WARN/PackageManager(60): Code path for pkg :
com.preciseinc.DroidLocator changing from /data/app/
com.preciseinc.DroidLocator-1.apk to /data/app/
com.preciseinc.DroidLocator-2.apk
12-29 13:55:48.954: WARN/PackageManager(60): Resource path for pkg :
com.preciseinc.DroidLocator changing from /data/app/
com.preciseinc.DroidLocator-1.apk to /data/app/
com.preciseinc.DroidLocator-2.apk
12-29 13:55:48.954: DEBUG/PackageManager(60):   Receivers:
com.preciseinc.DroidLocator.ServiceAutoStarter
12-29 13:55:48.974: INFO/ActivityManager(60): Force stopping package
com.preciseinc.DroidLocator uid=10040
12-29 13:55:49.134: INFO/installd(35): move /data/dalvik-cache/
d...@app@com.preciseinc.droidlocator-2@classes.dex - /data/dalvik-
cache/d...@app@com.preciseinc.droidlocator-2@classes.dex
12-29 13:55:49.144: DEBUG/PackageManager(60): New package installed
in /data/app/com.preciseinc.DroidLocator-2.apk
12-29 13:55:49.354: INFO/ActivityManager(60): Force stopping package
com.preciseinc.DroidLocator uid=10040
12-29 13:55:49.664: WARN/RecognitionManagerService(60): no available
voice recognition services found
12-29 13:55:49.844: DEBUG/dalvikvm(60): GC_FOR_MALLOC freed 8811
objects / 535480 bytes in 171ms
12-29 13:55:49.984: DEBUG/dalvikvm(60): GC_EXPLICIT freed 511
objects / 27096 bytes in 139ms
12-29 13:55:49.984: INFO/installd(35): unlink /data/dalvik-cache/
d...@app@com.preciseinc.droidlocator-1@classes.dex
12-29 13:55:49.994: DEBUG/AndroidRuntime(356): Shutting down VM
12-29 13:55:50.034: DEBUG/dalvikvm(356): Debugger has detached; object
registry had 1 entries
12-29 13:55:50.074: INFO/AndroidRuntime(356): NOTE: attach of thread
'Binder Thread #3' failed
--

Any ideas on why this is being terminated, and any workarounds? Any
and all help greatly appreciated.

Regards,

Raj Malhotra.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] HELP: Receiver killed on startup.

2010-12-29 Thread Mark Murphy
On Wed, Dec 29, 2010 at 2:04 PM, Raj rnmalho...@gmail.com wrote:
    I have a simple receiver that listens to the BOOT_COMPLETED
 action.

snip

 However, when I start debugging with an emulator, the apk gets
 installed, but the receiver process is terminated.

Of course.

Actually, your receiver process was probably terminated earlier, as a
manifest-registered BroadcastReceiver can only live for a few seconds,
tops.

 and any workarounds?

Don't install a new version of your APK.

To debug BOOT_COMPLETED receivers, add Log statements to your code and
reboot your emulator. Examine LogCat to see what happened. Adjust your
code. Lather, rinse, repeat.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] HELP: Receiver killed on startup.

2010-12-29 Thread Dianne Hackborn
On Wed, Dec 29, 2010 at 11:29 AM, Mark Murphy mmur...@commonsware.comwrote:

 To debug BOOT_COMPLETED receivers, add Log statements to your code and
 reboot your emulator. Examine LogCat to see what happened. Adjust your
 code. Lather, rinse, repeat.


You can also use adb shell am to send a BOOT_COMPLETED broadcast to your
app for quick testing.  I can't remember the exact syntax, but am help
will tell you.  Be sure to specific your explicit component name when doing
this, or you will cause all installed apps to re-run their boot completed
receivers, which may not be fun. :)

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en