Wednesday 15 April 2015

Start an Android Service from Command Line in Version-Agnostic way -


A 4.0.4 device will start any user option without successfully, but fails with it. 4.2.1 The device requires the --user option and fails without it.

How can I start the service in such a way that will work on all Android devices?

Or, if not possible, what's the criteria to determine - when user is required? $ adb shell getprop ro.build.version.release 4.0.4 $ adb starts open service - zero 0 -ei 123 -a com.a.activity.myservice error: unknown option : --Usage usage: am [subcommand] [options] {usage information $ adb shell getprop ro.build.version.release $ adb open am am startervice -ei 123 -a com.a.activity.myservice Servicing Service: Intent {act = com.a.activity.myervice (additional)} ~ / dev / dcf / application / spin (master) $ adb open am startervice -ei 123 -a com.a.activity.myservice Initial service : Intent {Act = com.apportable.a.myservice (additional)} java.lang.SecurityException: caller uid = 2000 on android.os at user = 2 Rights do not have to Nwad. Parasel.Radio Expression (Parcel.Avziny2525)

After Alex's suggestion, I wrote The following Python piece:

  result = env.Execute ([env ['ADB'], 'shell', 'am']) if the result is "--user": user_option = "- -user 0 "else: user_option =" "exec_line = 'startervice' + user_option + '-a' + app_id + '. GDB server service - Command start - GDbServer_name '+ Remote_GDBir ++' --II GDBarver_port '+ Str (env [' ANDROID_REMOTE_DEBUG_PORT '])    

No comments:

Post a Comment