سؤال

I want to find a way to create commands that I can send to my application using the adb shell or similar. This way I can do some small changes to my program without having to reload my application every time I change anything.

Is there a way to open the adb shell and send a command to a running application ?

If that is not possible, then what is a possible way to send commands to my application so I can do things like (Move the UI Elements) or (Create a file from a URL) or a number of other things.... Essentially I want to be able to send string commands to my application.....

If I can do that with the command line tools that would be sweet. otherwise What would be a good way to go about this ?

هل كانت مفيدة؟

المحلول

From an adb shell, type am. You can start activities and services as well as send broadcast intents. No arguments will print usage info.

From the host machine you can do adb shell am <command> if you want to invoke this from scripts.

نصائح أخرى

The adb shell am option is probably the cleanest/best/most awesome option, but you could have a Thread in your app checking for the presence of a specific file on the SD card. Something like (DON'T USE THIS CODE WITHOUT SERIOUS MODIFICATIONS):

public void run()
{
   File f = new File("/sdcard/appcommands");
   while(!stop){
      if(f.exists()){
         // read file
         // obey commands
         // remove file or use some other timing monitor
      }
   }
}

then you can just use adb push to write command files. Truly inefficient, but it can be made to work in a pinch. You can also do more complex things like creating local TCP/HTTP servers and using adb port forwarding, but that may just be overkill.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top