Python for Android
Within the tools directory, only two programs are of interest to you. The adb utility allows you to transfer files to (and from) your Android emulator (more on this utility later). The android tool lets you prepare and run an emulator for any number of the current Android releases, and that's what you do next:
$ cd Android/tools $ ./android
The android command starts the Android SDK and AVD Manager, which is a tool that creates Android emulators for any number of Android virtual devices. At the moment, there are no virtual devices, so you need to create one. However, before this can happen, you need to install a target Android API package. To do that, click on the Installed Packages tab, then press the Update All button. In the dialog that appears, click Accept All and then press the Install button.
The resulting download takes a while, so drag yourself away from your computer and head off into the kitchen to make a nice cup of coffee. Depending on your download speed, you may have time to make a quick sandwich too.
With the download(s) complete, let's create an Android Virtual Device (AVD). An AVD is a virtual version of an Android device that you can run on the emulator. Select the Virtual Devices tab, then click on the New button. A dialog appears that you can use to set the characteristics of your AVD. Figure 1 shows that I've given my AVD a name (LJapp), selected an API target (API Level 7, which is Android 2.1) and set my virtual SD card to 256 meg. When you have made your selections, click on the Create AVD button to initialize your AVD.
If you return to the Virtual Devices tab, your LJapp AVD now should exist. Select the AVD and press the Start button, then select the Launch button from the displayed dialog. The emulator starts to load, and after a few seconds, you see the opening screen for your emulated Android device (Figure 2). Note that the emulator runs much more slowly than the actual physical phone, so it may take a while to get to the Android startup screen. Your mileage will vary, depending on the speed of your desktop's processor.
Note: throughout the remainder of this article, I use the word “tap” to refer to using the mouse to click within the emulator. There is no mouse pointer on your physical Android device (that's what your finger is for), but the emulator needs something, so the mouse pointer “emulates” your finger, hence the use of the word tap to describe the action required. When you see me use the word tap, think click.
Getting the SL4A on your emulator is straightforward. Start by tapping the Android browser and surfing to the SL4A Web site: code.google.com/p/android-scripting.
When the SL4A Web page appears, tap on the square graphic (the QR Code) to access the download URL for SL4A. The download should begin immediately, and once it completes, tap the downloaded package name (which is sl4a_r3.apk at the time of this writing) to install SL4A. Go ahead and tap on the Install button, then tap on the Open button to start the app. You'll be asked to participate in usage tracking (it's up to you, and it's optional), and then SL4A informs you that you have “No matches found” under your Scripts listing. That's okay; you've yet to install any scripts. SL4A now is ready for Python.
Return to the Android browser and double-tap the screen to enlarge the Web page. Locate the Featured Downloads part of the page on the right, and tap on the download arrow beside the python_for_android_r1.apk link. As before, let the download complete before tapping on the downloaded file to install it. When you're ready, tap the Install button to confirm the installation of the interpreter. When this completes, tap on the Open button, then tap on the big Install button to complete the installation. The Python for Android app downloads, extracts and installs the Python support files from the SL4A Web site and adds them into SL4A. The entire process should take only a minute or two to complete. If it takes longer than a few minutes, take a deep breath, and remember that the emulator is much slower than your physical device.
When the installation completes, you'll be presented with an Uninstall button. Don't tap this button! If you do, you'll remove the Python interpreter that you've just installed. Instead, tap on the emulator's home button (the little house icon) to return to the Android main screen, tap the tab at the bottom of the screen to see the list of installed apps, and note that SL4A has been added to your emulator (Figure 3).
Go ahead and tap the SL4A icon that now displays the list of installed Python scripts. Tapping the hello_world.py script pops up the SL4A run menu (Figure 4). Looking from left to right, the menu icons have the following meaning: 1) run the script at the Python shell, which is useful when debugging; 2) run the script “natively”; 3) edit the script in SL4A's built-in text editor, which is useful only for the most trivial of changes; 4) rename the script; and 5) delete the script. To test your installation quickly, tap the second menu icon, which I like to refer to as the “run wheel”. After a second or two, a message saying “Hello, Android!” appears on screen for a few seconds then disappears.

Figure 4. SL4A Menu Icons
If that worked, tap the test.py script, then tap the run wheel. This runs a longer-running script that showcases some of the facilities available to you as a Python programmer working on Android. Again, bear in mind that the emulator runs slowly, so be patient and wait for the various Android interface elements to appear.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- seo services in india
18 min 14 sec ago - For KDE install kio-mtp
18 min 56 sec ago - Evernote is much more...
2 hours 19 min ago - Reply to comment | Linux Journal
11 hours 4 min ago - Dynamic DNS
11 hours 38 min ago - Reply to comment | Linux Journal
12 hours 37 min ago - Reply to comment | Linux Journal
13 hours 27 min ago - Not free anymore
17 hours 29 min ago - Great
21 hours 16 min ago - Reply to comment | Linux Journal
21 hours 24 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?







Comments
Looks like Paul's been time
Looks like Paul's been time travelling again. i like the article though. It covers exactly what i have spent the past hour searching for.
Well at least you got the
Well at least you got the info a week early! ;) This is a very comprehensive article about app programming. While I don't have the technical expertise to craft the SL4a technique without conquering a steep learning curve, it does open my eyes to a new way to do things. This is particularly helpful since I've been learning how mobile solutions are being tapped into by users. As one can imagine, a company that does mobile marketing(example: http://www.exacttarget.com) is going to have different needs then a company that specializes in manufacturing, or a user who wants to simplify his/her "mobile" life. Right now I fall into the latter category, but that doesn't mean I won't have a vastly different agenda in regards to app programming in the future.
Time will tell if Android development via Python is something I will tap into, but it's nice to have the programming app horizon broadened. Options are good!
Amazing!
this essay is posted on "Apr 30, 2011 By Paul Barry in Mobile". And today is Apr 23.
I noticed that to. I wonder
I noticed that to. I wonder what planet he was on when he published the article.