Hey,
I'm working on a background service that is going to be triggered by the
alarm manager. I've set everything up for my broadcast receiver, though
I'd like to test it without having to write a bunch of Java code. After
looking around a bit I've come across this *am *tool that appears to do
what I need, though I don't know how to create a specific broadcast intent.
Let's say my BroadcastReceiver is com.foo.receiver.NiftyReceiver and I have
it in my manifest file as <receiver android:name=".receiver.NiftyReceiver"
/>
The documentation is a bit lacking on how to use the tool, but after a bit
of confusion I've finally figured out how to get it working.
am broadcast -n com.foo/com.foo.receiver.NiftyReceiver
Note, you need to add the android:exported="true" to your <receiver>
otherwise android will spew this nifty little error message on you:
W/ActivityManager(16908): Permission denied: checkComponentPermission()
reqUid=10066
W/ActivityManager(16908): Permission Denial: broadcasting Intent {
cmp=com.foo/.receiver.NiftyReceiver } from null (pid=1411, uid=2000)
requires null due to receiver com.foo/com.foo.receiver.NiftyReceiver
I'm pretty sure this isn't anything new, but I personally found tools like
am aren't really documented that well. Hopefully this will save someone
else a bit of time in the future!
--
Christopher Saunders
http://christophersaunders.ca/
Cool. I got a ton of mileage out of "am" while adding features to the internal android manager. "dumpsys" is also another really cool tool that's available a/t adb shell. IIRC the source for all of the tools is in the public repo. Well worth figuring out all of them. Hmm... This might be something to present on the 18th? Don/ On Thu, Jan 5, 2012 at 22:29, Christopher Saunders <c.saunders322@gmail.com> wrote: > Hey, > > I'm working on a background service that is going to be triggered by the > alarm manager. I've set everything up for my broadcast receiver, though I'd > like to test it without having to write a bunch of Java code. After looking > around a bit I've come across this am tool that appears to do what I need, > though I don't know how to create a specific broadcast intent. > > Let's say my BroadcastReceiver is com.foo.receiver.NiftyReceiver and I have > it in my manifest file as <receiver android:name=".receiver.NiftyReceiver" > /> > > The documentation is a bit lacking on how to use the tool, but after a bit > of confusion I've finally figured out how to get it working. > > am broadcast -n com.foo/com.foo.receiver.NiftyReceiver > > Note, you need to add the android:exported="true" to your <receiver> > otherwise android will spew this nifty little error message on you: > > W/ActivityManager(16908): Permission denied: checkComponentPermission() > reqUid=10066 > W/ActivityManager(16908): Permission Denial: broadcasting Intent { > cmp=com.foo/.receiver.NiftyReceiver } from null (pid=1411, uid=2000) > requires null due to receiver com.foo/com.foo.receiver.NiftyReceiver > > I'm pretty sure this isn't anything new, but I personally found tools like > am aren't really documented that well. Hopefully this will save someone > else a bit of time in the future! > > -- > Christopher Saunders > http://christophersaunders.ca/ -- http://hi.im/donkelly https://github.com/karfai
It would be neat if someone (Don?) touched on these. There's so many things that are just there on your device that I don't think a lot of people know about! On Thu, Jan 5, 2012 at 10:35 PM, Don Kelly <karfai@gmail.com> wrote: > Cool. I got a ton of mileage out of "am" while adding features to the > internal android manager. "dumpsys" is also another really cool tool > that's available a/t adb shell. IIRC the source for all of the tools > is in the public repo. Well worth figuring out all of them. > > Hmm... This might be something to present on the 18th? > > Don/ > > On Thu, Jan 5, 2012 at 22:29, Christopher Saunders > <c.saunders322@gmail.com> wrote: > > Hey, > > > > I'm working on a background service that is going to be triggered by the > > alarm manager. I've set everything up for my broadcast receiver, though > I'd > > like to test it without having to write a bunch of Java code. After > looking > > around a bit I've come across this am tool that appears to do what I > need, > > though I don't know how to create a specific broadcast intent. > > > > Let's say my BroadcastReceiver is com.foo.receiver.NiftyReceiver and I > have > > it in my manifest file as <receiver > android:name=".receiver.NiftyReceiver" > > /> > > > > The documentation is a bit lacking on how to use the tool, but after a > bit > > of confusion I've finally figured out how to get it working. > > > > am broadcast -n com.foo/com.foo.receiver.NiftyReceiver > > > > Note, you need to add the android:exported="true" to your <receiver> > > otherwise android will spew this nifty little error message on you: > > > > W/ActivityManager(16908): Permission denied: checkComponentPermission() > > reqUid=10066 > > W/ActivityManager(16908): Permission Denial: broadcasting Intent { > > cmp=com.foo/.receiver.NiftyReceiver } from null (pid=1411, uid=2000) > > requires null due to receiver com.foo/com.foo.receiver.NiftyReceiver > > > > I'm pretty sure this isn't anything new, but I personally found tools > like > > am aren't really documented that well. Hopefully this will save someone > > else a bit of time in the future! > > > > -- > > Christopher Saunders > > http://christophersaunders.ca/ > > > > -- > http://hi.im/donkelly > https://github.com/karfai > -- Christopher Saunders http://christophersaunders.ca/