dcsimg

Writing an Android Twitter Client with Python

Get up and running with the Android Scripting Environment. Whip up a Twitter update app in a matter of minutes and tell everyone what sandwich you're eating from within Android!

There are many Android tutorials on the Internet and books in the bookstores showing how to write applications — I know, I’ve read many of them and have even been fortunate enough to have the opportunity to write a few myself. Up until this point, every Android application I have seen has been written in Java with a few of the more intrepid tutorials covering the topic of getting a “C” application to run on Android.

While writing applications in Java and the Android SDK is really pretty easy for a coder with an interest in learning the SDK, there is a bit of a learning curve in getting the tools setup, navigating the SDK and getting your application to run happily on the device. If you are looking to write an application for the Android Market, using the SDK is the way to go.

But what if you are interested in just hacking around a little on the device itself? What if you’re looking for a mobile Internet device that you can program anywhere — even while you are waiting patiently at the doctor’s office?

With the Android Scripting Environment, you can do just that! If you are familiar (or willing to learn) Python, Lua, or BeanShell, you can write applications directly on your Android device — no laptops, no compilers, no kidding. Follow along as we learn about the Android Scripting Environment and create a script in Python to submit entries to your Twitter account.

Android Scripting Environment

The Android Scripting Environment (ASE) installs to your Android device just like any other Android application. You can download the ASE installation file from its project page on googlecode.com. I have the alpha 0.7 version of ASE installed on my development phone.

You can use ASE to write applications much as you would in any Linux environment. Interact with the user, perform calculations, connect to the Internet. You can even access a subset of the Android SDK functionality from the scripting environment such as reading Android’s sensors and launch other applications. This flexibility allows an experienced developer (or script writer) to customize the Android environment without having to go the SDK development route. Scripts can be installed as a Service to be available at all times or be even triggered by the Locales plugin.

Once the ASE application is installed and launched on your Android phone, you will see the “Script Manager” where all activity is initiated.

Script Manager
Script Manager

The ASE installs with a handful of sample scripts which demonstrate basic scripting functionality. Clicking on any of the scripts will start the script in a new terminal window using the appropriate script interpreter engine. The file extension determines which interpreter is launched.

For example, a script with a “.bsh” extension is processed via the BeanShell interpreter. To create a new script, select the menu button and choose “Add”. If you want to enter script commands directly into the interpreter, choose the “Terminal” menu selection. You can choose from each of the supported and installed script interpreters. To edit or delete an existing script, perform a long-click (press and hold) of the selection.

Script Editing Actions
Script Editing Actions

Note that you can also create a shortcut on the home/launch window. This is helpful if you write something useful (of course you will!) and want to be able to launch it quickly. I created a shortcut to my “Twitter Status” script, which is in the script file named ts.py.

Script Editing Actions
Script Editing Actions

It is time to have a look at our script. To test this script, you will require an Android device (or emulator) with internet access. As already mentioned, you can edit scripts directly on the device through the ASE ScriptManager code window, however you may not want to type all of the code directly into your device. Good news — you can simply copy the file to your device as a starting point.

Next: Confessions of a Python Newbie

Comments on "Writing an Android Twitter Client with Python"

If yoou w?nt t? play games on ?ine ?nside you? free time, yo? mig?t
t?o get paid for h?ving fun!

?h?re ??? the web sites th?t wil? pay their customers
t? play games, ?ead e-mails, ?nd join online survey panels.

Feel free t? visit my webpage :: http://xrambo.com/blog/1553228

If you ha?e a PCand ?ike ?resenting yo?r viewpoint, y?u m?ght ne?d to tr? performing onlin surveys f?om ??m? whi?e tr?ing services
to produce ? litt?e supplemental income.

Feel free t? visit my web page … äugender

Hi, Neat post. There is a problem along with your site in internet explorer, may check this… IE still is the market chief and a good portion of other folks will pass over your wonderful writing because of this problem.

Hi, Neat post. There is an issue together with your site in web explorer, might check this?
IE still is the market chief and a good component to people
will pass over your wonderful writing because of this problem.

Just want to ?ay yo?r article iss as astonishing.

Thee clearness ?n your put up is simply ?reat and i couldd suppose ?o?’re a professional on this subject.

We?l ?ith youhr permission ?llow me to snatch ?our
feed to ?eep up to date ?ith imminent post. ?hank y?u a m?llion andd p?ease carry on the enjoyable ?ork.

All six models both in shirt is for players who use a weapon,
you fallout shelter cheats should also emphasis on the
iPhone 4s, the greatest football game indeed.

And making an attempt to clarify the puzzles and cornfield
was tough.

Wonderful story, reckoned we could combine a few unrelated data, nonetheless actually really worth taking a look, whoa did a single find out about Mid East has got much more problerms as well.

Check beneath, are some completely unrelated web sites to ours, however, they’re most trustworthy sources that we use.

Please visit the sites we stick to, which includes this a single, because it represents our picks through the web.

Just beneath, are various absolutely not associated web-sites to ours, having said that, they’re certainly worth going over.

Every as soon as inside a when we select blogs that we read. Listed beneath would be the latest sites that we select.

Here is a superb Blog You may Discover Fascinating that we encourage you to visit.

I like this weblog very much, Its a very nice billet to read and obtain info . “Education is the best provision for old age.” by Aristotle.

Always a big fan of linking to bloggers that I really like but don?t get a whole lot of link like from.

Everything will be carried out one hundred% protected and safe.
So what are you ready for?

The information and facts mentioned in the article are a number of the ideal available.

The information and facts talked about inside the post are some of the most beneficial available.

Here are some hyperlinks to websites that we link to because we consider they are worth visiting.

Here are some of the web sites we advocate for our visitors.

Usually posts some extremely exciting stuff like this. If you?re new to this site.

The information and facts mentioned within the report are some of the very best offered.

Here is a good Blog You may Uncover Interesting that we encourage you to visit.

Always a big fan of linking to bloggers that I like but do not get quite a bit of link like from.

Opt for a few demure prints to raise your tailor-made haberdashery look when you give ones suit, activity
coat, or perhaps casual outfit greater adaptability and comfort.

A classic watch in leather or metal band is the safest.
And not to mention stylish, high fashion, eye candy.

Review my web site :: louboutin sneakers men

Hmm it looks like yohr site ate my first comment (it was extremely long) so I guess
I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog.
I as well am an aspiring blokg blogger but I’m still new to everything.
Do you have any helpful hints for beginner blog writers?

I’d certainly appreciate it.

my web-site; dog obedience harlow [Moshe]

Here are several of the internet sites we advise for our visitors.

The time to study or stop by the subject material or web pages we’ve linked to below.

Here is a superb Weblog You might Come across Intriguing that we encourage you to visit.

That is the finish of this report. Right here you will locate some internet sites that we consider you will enjoy, just click the links.

Wonderful story, reckoned we could combine a number of unrelated information, nevertheless actually really worth taking a look, whoa did 1 study about Mid East has got extra problerms also.

I have been browsing online more than three
hours today, yet I never found any interesting article like yours.
It is pretty worth enough for me. In my view, if all web owners and
bloggers made good content as you did, the web will be
much more useful than ever before.

Leave a Reply