1

I have tried to use this command : adb shell am startservice com.bytel.velizy.automation/.ExchangeService -es "begin" "lol" -es "priority" "hjhjhj" but it's seems that my Android app doesn't receive Extras "begin" and "priority"

I have these lines in my service ExchangeService :

    if(intent.hasExtra("begin") && intent.hasExtra("priority")){
        Log.i("AUTOMATION_ADB" , "EXTRAS : " + intent.getStringExtra("begin") + " " + intent.getStringExtra("priority") );
    }else{
        Log.i("AUTOMATION_ADB" , "NOTHING" );
    }

I get the "Nothing" in the logcat;

in the cmd command I have this message :

Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.bytel.velizy.automation/.ExchangeService launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }

How can I pass Extras using ADB for startservice ?

Addev
  • 31,819
  • 51
  • 183
  • 302
Ilan
  • 729
  • 3
  • 8
  • 17
  • from the help: `[-e|--es ...]` - did you try `-e` or `--es` ? – pskink Oct 30 '17 at 08:38
  • I have tried this 'adb shell am startservice com.bytel.velizy.automation/.ExchangeService --es "begin" "lol" --es "priority" "hjhjhj"' Is it that or I misunderstood? 'Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.bytel.velizy.automation/.ExchangeService launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }' – Ilan Oct 30 '17 at 08:43
  • yes, `--es` is ok – pskink Oct 30 '17 at 08:46
  • I have still the "Nothing" in my logcat – Ilan Oct 30 '17 at 08:47
  • 1
    try `adb shell am startservice --es begin end --es priority nopriority com.bytel.velizy.automation/.ExchangeService` – pskink Oct 30 '17 at 09:09
  • I have forgotten the **-n** And the correct command is : **adb shell am startservice -n com.bytel.velizy.automation/.ExchangeService --es begin lol --es priority oiii** I get in the cmd **Starting service: Intent { cmp=com.bytel.velizy.automation/.ExchangeService launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } (has extras) }** Your command works as well ! Thanks for you help :) – Ilan Oct 30 '17 at 09:13
  • you dont need **-n** (see my prev comment) – pskink Oct 30 '17 at 09:15
  • Thank you very much @pskink ! – Ilan Oct 30 '17 at 09:16
  • sure, your welcome – pskink Oct 30 '17 at 09:16

0 Answers0