Issue
I registered a broadcast receiver in the MainActivity.onCreate
method with the following statements:
...
// in onCreate()
val filter = IntentFilter("com.example.my_receiver.TEST_FILTER")
registerReceiver(myReceiver, filter)
...
with the following receiver
private val myReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
// do something
}
}
when I executed the add command
adb shell am broadcast -a com.example.my_receiver.TEST_FILTER
the onReceive
method will be executed. But when I try to add some extra data with the following
adb shell am broadcast -a com.example.my_receiver.TEST_FILTER --es test_data "My testdata"
nothing will be executed. How can I send extra data with adb
and receive it in the BroadcastReceiver
implementation? The compileSdk
and targetSdk
is 31.
Solution
I would recommend that you try without whitespace in the first place, or just escape the whitespace, seen also here:
adb command fail to execute if path contain spaces
Answered By - Florian Knoll
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.