Search code examples
javaandroidserviceinject

Is passing code to a service class possible in Android/Java?


I'm trying to let a user "make his own service". most direct method I could think of is creating an empty service and letting him "fill it". he will write his own code and I'll compile it along with my project. (If it's not understood, the code should be injected to the service programmaticaly and not manually).

There are limitations that require it's done this way.


Solution

  • Here's a post about programmatically compiling and running Java code,

    How do I programmatically compile and instantiate a Java class?

    This is pretty ugly though. You might want to look at having the use supply a script in a higher level language, and executing it via the android scripting environment,

    http://google-opensource.blogspot.com/2009/06/introducing-android-scripting.html

    There's also the SL4a project,

    http://code.google.com/p/android-scripting/