0

I've sent intents without extras to my SyncReceiver(BroadcastReceiver) successfully using

adb -s <ip_address> shell am broadcast -a com.istock.ALERT

However when I add extras the OnReceive event of SyncReceiver is never called, an example of sending an intent with extras

adb -s <ip_address> shell am broadcast -a com.istock.ALERT --es title "Alert Title"

I found a post on SO with pretty much the same issue, however when I implement the fix it still doesn't call the OnReceive event of the SyncReceiver

adb -s <ip_address> shell am broadcast -a com.istock.ALERT -n com.istock/.SyncReceiver --es title "Alert Title"

At this point I just don't understand why I can receive intents without extras sent via adb and am unable to receive intents with extras any idea?

nulltron
  • 637
  • 1
  • 9
  • 25

1 Answers1

0

My issue was cause by using the command in one line, once I separated the command into 2 parts it worked as intended.

ORIGINAL:

adb -s <ip_address> shell am broadcast -a com.istock.ALERT --es title "Alert Title"

WORKING:

adb -s <ip_address> shell

am broadcast -a com.istock.ALERT --es title "Alert Title"

ULTIMATE SOLUTION:

I really wanted to be able to do this in one line (it would make it easier to work into a Mobile Device Management (MDM) Application. Thanks to @Alex P. for his answer on this post.

ADB seems to mangle the strings encapsulated in Double Quotes ("") a work around he suggests works, just use single quotes ('').

adb -s <ip_address> shell am broadcast -a com.istock.ALERT --es title 'Alert Title' --es message 'Alert Message'
nulltron
  • 637
  • 1
  • 9
  • 25