SL4A Interview Questions & Answers

  1. Question 1. What Is Scripting Layer For Android (sl4a) For?

    Answer :

    SL4A 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. 

  2. Question 2. Why Sl4a? Android Programs Are Easy Enough To Write.?

    Answer :

    That’s very true. Android’s development environment does make life pretty easy. But, you’re tied to a computer to do your work. SL4A lets you try out an idea now, in the situation where you need it, quickly.

  3. Perl Scripting Interview Questions

  4. Question 3. How Does Sl4a Work?

    Answer :

    SL4A provides Android facades which make APIs available via JSON RPC calls. Only the parts of Android’s APIs which has been wrapped by facades are available to interpreters.

  5. Question 4. Does Sl4a Compile The Supported Languages To Dex Bytecode Or Is There An Additional Layer Of Interpretation?

    Answer :

    It depends on the language a bit. BeanShell is run in the JVM and has an additional layer of interpretation. Lua, Python, and Perl are actually the C versions running natively.

    All interaction with Android is over RPC channels. Still, the RPC API is compiled to dex so there’s no additional interpretation in Java (other than reflection).

  6. Perl Scripting Tutorial

  7. Question 5. What About Performance?

    Answer :

    With respect to the interpreters SL4A 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 Android facades, 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.” SL4A 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.

  8. Python Interview Questions

  9. Question 6. Are Scripts First-class Apps From The Point Of View Of The System?

    Answer :

    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.

    It is not currently possible to write a script that will exit with a result (e.g. another Android activity starts your activity for result).

  10. Question 7. Is This A Complete Api Bridge, Or Are There Restrictions?

    Answer :

    BeanShell, JRuby, and Rhino basically give you a complete API bridge (you can invoke Java calls directly). See the documentation for those interpreters for instruction on how to accomplish this. Cross compiled languages like Lua are more restricted. They only have access to the APIs exposed through the RPC layer. 

  11. Python Tutorial
    IBM-REXX Interview Questions

  12. Question 8. What Do I Do With All These Barcodes?

    Answer :

    Barcodes are a easy way to access a web link on your phone (e.g. to download SL4A). 

  13. Question 9. Where Are The Sample Scripts And Other Interpreters?

    Answer :

    As of release 0.8 alpha, interpreters and sample scripts are distributed separately. Please read InstallingInterpreters for directions on how to add them.

  14. Ruby Interview Questions

  15. Question 10. Can I Run Scripts As Root?

    Answer :

    If you have a rooted phone, you may be interested in doing so. At the moment, SL4A does not support this directly. 

  16. IBM-REXX Tutorial

  17. Question 11. How Do I Install Sl4a?

    Answer :

    1. Enable “Unknown Sources” under Application settings.
    2. Install Barcode Scanner.
    3. Scan the barcode on the home page to download the APK.
    4. Tap on the downloaded APK to install SL4A.
  18. Javascript Advanced Interview Questions

  19. Question 12. Can I Use Sl4a To Write A Real Android Application Or Embed Sl4a Scripts In My Application?

    Answer :

    Yes! You can embed your script in a (mostly) stand alone APK.

  20. Perl Scripting Interview Questions

  21. Question 13. Will Sl4a Work On An Android Emulator?

    Answer :

    Yes. Use adb install sl4a_rnn.apk to install it to the emulator.

  22. Javascript Advanced Tutorial

  23. Question 14. Will Sl4a Work On My Android Device That’s Not Built On Arm (e.g. X86)?

    Answer :

    Yes and no. All cross compiled interpreters are compiled for ARM. Java based interpreters like JRuby, BeanShell, and Rhino will work.

  24. Question 15. Can I Run An Sl4a Script From My Application?

    Answer :

    Yes. See IntentBuilders.java.

  25. Java Bean Utils Interview Questions

  26. Question 16. My Script Stops Working When The Screen Turns Off! Wtf?

    Answer :

    Your phone turns the screen off, among other things, when it goes to sleep. If an application doesn’t request that it keep running when the phone is asleep, it will stop running until the phone wakes up again (i.e. you turn the screen back on). Requesting that the device remain on while your application is running is called a wake lock.

    SL4A provides APIs for acquiring and releasing wake locks. It is important to note that wake locks significantly impact battery life. You should always release a wake lock as soon as possible.

    Instead of using a wake lock, you can also enable the “Stay awake” system setting. From your home screen tap Menu, Applications, Development, and check Stay awake. With that enabled, your phone will never sleep while charging. This does affect the amount of time it takes to charge your phone, however.

  27. Ruby on Rails 2.1 Tutorial

  28. Question 17. Can I Use Sl4a For Ui Automation?

    Answer :

    No. For security reasons, it is only possible for the shell user to inject UI events into arbitrary applications. See UI/Application Excersier in the Android documentation.

  29. Rhinoceros 3D Interview Questions

  30. Question 18. What Usage Information Does Sl4a Collect?

    Answer :

    If you enable “Usage Tracking”, the application will collect anonymous usage information through Google Analytics.

  31. Python Interview Questions

  32. Question 19. Where’s Javascript?

    Answer :

    JavaScript is implemented using the Mozilla Rhino project and V8. Look for “Rhino” in the interpreter downloads. Or, write an HTML script to use V8.

  33. Java Bean Utils Tutorial

  34. Question 20. Where’s Php?

    Answer :

    There is a PHP interpreter, which is a separate project. The PHP installer and interpreter can be found there.

  35. wxPython Interview Questions

  36. Question 21. What’s Logcat?

    Answer :

    Logcat is a rotating log of messages that Android produces. It’s a very useful tool for programmers to work out what exactly is going on if someone reports and error. It’s a requirement in our Issues reporting to attach a logcat wherever possible. 

  37. Question 22. Sl4a Won’t Install Interpreters On An Emulator?

    Answer :

    In fact, SL4A works fine on emulators, having been to a large degree developed on them. But these interpreters require a bit of room, and the default AVD size for a sdcard is on 16Mb. This is inadequate. I would allocate a minimum of 128Mb, and in fact commonly set mine to 512Mb. Bear in mind that it’s unusual to get an Android device with less than 2Gb these days.

  38. wxPython Tutorial