|
FAQ
Frequently asked questions.
Still having trouble? Still got questions? Try the ASE discussion group. What is Android Scripting Environment (ASE) for?ASE makes it possible to quickly prototype applications for Android on the device itself using high-level scripting languages. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface. Have a look at some of the example scripts to see for yourself. Why ASE? Android programs are easy enough to write.That's very true. Android's development environment does make life pretty easy. But, you're tied to a computer to do your work. ASE lets you try out an idea now, in the situation where you need it, quickly. After that, you can take what you learned and turn it into a real application! How does ASE work?For some scripting languages, like BeanShell, it's possible to access Android's Java API directly. The AndroidFacade is available for use by these languages for convenience. For other languages, like Python and Lua, the API is made available via JSON RPC calls to a proxy. Only the part of the API which has been wrapped by the AndroidFacade and AndroidProxy are available to cross-compiled interpreters like Python and Lua. Does ASE compile the supported languages to Dex bytecode or is there an additional layer of interpretation?It depends on the language a bit. BeanShell is run in the JVM and as an additional layer of interpretation. Lua (and eventually Python) are actually the C versions running natively. Their interaction with Android is over an RPC channel. Still, the RPC API is compiled to dex so there's no additional interpretation in Java (though there is reflection). What about performance?With respect to the interpreters ASE provides, Lua and Python are both cross compiled C binaries that run in their own process. CPython is significantly more performant than Jython (especially since Android does not currently support JIT). As for the AndroidFacade, the API is primarily focused on making it easier to write scripts than on the performance of those scripts. That said, remember the adage "measure first, then optimize." ASE is about rapid development after all. If you have performance concerns for your application, it's probably better to use the standard Android SDK (or NDK) where you'll have more control over the system. Is there a (long-term) goal to permit writing Android apps in these other supported languages, or is it just for quick and dirty experimentation?This is possible. However, the first priority is to make the existing system stable, more user friendly, and to provide more comprehensive access to the Android APIs. Are scripts first-class apps from the point of view of the system?Yes, mostly. You can invoke arbitrary intents and there are also plans to support broadcast receiver scripts. That is, you could write an app that consumes photos and shows up in the list of apps when the user presses Share in the Camera app. Is this a complete API bridge, or are there restrictions?BeanShell basically gives you a complete API bridge (you can invoke Java calls directly). Cross compiled languages like Lua are more restricted. They only have access to the APIs exposed through the RPC layer. However, the RPC layer is easy to extend. TTS isn't working!First, make sure you've installed TTS support. It's available in the Market: just search for TTS. If you have it installed, run the TTS activity and try playing the sample sound. If you can't hear it, try turning up the volume. Once that works, try your script again in ASE. If you have Donut, TTS comes with the phone. Check your phone's speech synthesis settings. Where are the sample scripts and other interpreters?As of release 0.8 alpha, interpreters and sample scripts are distributed separately. Please read InstallingInterpreters for directions on how to add them. I found a bug and I have a great idea!Be sure to have a look at the issues page to see if your issue is known or if your suggested enhancement is already planned. |
Sign in to add a comment
Is it possible to call/execute a Lua script from within a Java application ?
Yes, you just need to do a startActivity with the ASE launch script intent.
Is it possible to make a SMS Lua script using an activity like android.call ?
@pepj2000 Yes, you can send text messages from Lua scripts.
@daonkohler: I know I can send, but i've to write number, instead using android.call i can pick a contacto from contact list
@pepj2000 Ah, now I understand. You can use the ASE pickContact API to pick a contact and then get the phone number from that.
I've tried to get number from that, but it's wrong number.
@pepj2000 I'll have to try to reproduce the error. Please file an issue.
Is it possible to run the scripts as root? I try to issue a SU or SUDO, but the script finishes when calling these commands...
Is there a possibility to access the Android API-functions from BeanShell? without the use of call() as in the Hello World! example? Is there any tutorial or some more examples about BeanShell? and ASE? I've used google quite a lot but didn't find anything usable (just about lua and python).
Currently scripts are run as the ASE user. You could run them as root by invoking the interpreter yourself in a root shell.
@applican I suggest starting with the BeanShell documentation. Be prepared for it to get hairy though :)
But how to invoking a interpreter as root?
@damonkohler I am using your launch script intent, which works very well for me (thx).. but there is still an open question, how can I pass extra arguments to a scripts. is it possible to use i.putExtra("key",value), how do I have to access them in my script?
Does JavaFX work?
@baolijian ASE runs as itself (i.e. the user assigned by Android when it is installed). You could open a shell, su, and then execute the interpreters on your own though to run them as root.
@DerGraf? Passing in and retrieving arbitrary extras isn't yet supported.
@raphaelmiranda Take a look at the Android documentation to see what Java libraries are available on the platform.
Hi damonkohler, I have some questions for you: