SL4A Interview Questions & Answers

5 avg. rating (100% score) - 1 votes

SL4A Interview Questions & Answers

Ready to face interview for SL4A? Do not worry, we are here to help you with job interview preparation. If you are preparing SL4A interview and not sure which questions are likely asked in interview, we suggest you to go through Wisdomjobs interview questions and answers page to crack your job interview. SL4A is a library used in creating and running of scripts. Any scripting language like Python, Perl etc. can use this library on android. It is specifically designed for android devices as SL4A stands for Scripting Layer for Android. Strong technical skills are needed as there is huge competition. Below is the list of frequently asked SL4A interview questions and answers which gets you ready to face the interviews:

SL4A Interview Questions

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

    4. 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).

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

    6. 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).

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

    8. 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). 

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

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

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

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

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

      Answer :

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

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

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

      Answer :

      Yes. See IntentBuilders.java.

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

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

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

      Answer :

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

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

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

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

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

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SL4A Tutorial