Kamis, 06 Agustus 2009

Creating an App Widget with Custom Timing

App Widgets are a popular new feature with the Android 1.5 SDK. Writing a basic App Widget would seem straightforward, however some properties turn out to get in the way of simple features.
The Android documentation for App Widgets references the ability to let users choose the duration between updates. In practice, the update duration property of an App Widget is immutable. Our latest article on developer.com addresses this, giving code and instruction on creating an Android App Widget with a user-customizable update duration.

Selasa, 28 Juli 2009

When "Eclipse loading framework information into layout resource editor" Fails

The Android Development Plug-in for Eclipse is a great tool many Android developers rely upon. I personally use some features much more than others. For example, I rarely use the Layout Resource editor to preview layout files. Instead, I just edit the XML directly and run it in the Emulator. (I have also been known to edit HTML with notepad, that's just how I roll.)

So it came as a bit of a surprise (read: annoyance) when I tried to do just that--preview a layout file in Eclipse--the other day and it failed. Eclipse seemed to try to load the layout designer saying, "Eclipse is loading framework information and the Layout library from the SDK folder." Then it up and failed to load it. Over and over. You couldn't see the layout preview, nor the Properties pane or the Outline mode to add new controls to the layout tree.

You might be wondering why I bothered to investigate this since I could have just gone back to the XML and blown it off. Well, I needed a screenshot of the Layout preview mode for our new book. Nuff said.

At first, I thought it was just me overestimating the tool's abilities, trying to preview a layout that was too complex for the preview (this happens often when I include some of the more complex View controls in layouts). So I created a new project with its simple default layout file, and that didn't load either. So that wasn't it.

I did a quick search on the Android developer forums and a couple people were complaining on the forums about this over a year ago. One person suggested recreating your workspace. Well, that didn't work, either. I widened my search to the web and ran across a little note on Brian Klug's wiki, suggesting that the older versions of the Android plug-in JAR files might be hanging around, mucking things up. Thanks, Brian! This sent me in the right direction.

We've had a number of new revisions of Android lately. which have improved (greatly) the Android tool chain, that have had several new JAR file updates. Next, I had to find the android JAR files on my machine. First, I checked where Brian had suggested: c:\eclipse\plugins (basically, in the plugins directory of the eclipse installation path). As my luck would have it, they were not there. Instead, a quick file search for "com.android*.jar" showed that they were hiding in C:\Users\YourUserName\.eclipse\org.eclipse.platform_3.4.0_867647348\features.

With a little investigation, I found several older versions (0.8.x and 0.9.0) of the android JAR files installed with the new ones (0.9.1 is the latest for Android SDK 1.5 r3). I shut down Eclipse, deleted all the older JAR files, leaving only the 0.9.1 versions.
Specifically, I only kept these two android JAR files:
  • com.android.ide.eclipse.adt_0.9.1.v200905011822-1621
  • com.android.ide.eclipse.ddms_0.9.1.v200905011822-1621
When I relaunched Eclipse, the layout preview began to function again. Incidentally, this was on a Windows installation of the Android tools. When I checked the Mac install of Android 1.5 R3, the JAR files were hanging about in (rather than the expected /Developer/Applications/eclipse/plugins~/.eclipse), but the layout preview did load without issue.

Sabtu, 18 Juli 2009

Run Android on Your Machine with LiveAndroid

LiveAndroid, a community project hosted at Google Code open source hosting, is determined to make a LiveCD that will run Android on a typical Intel-based laptop. As of their second release, many things work, including the mouse. The LiveCD will easily boot in the free VirtualBox environment, and can boot on many machines, too. Their work is based on previous work done to port Android to the Asus eee 701.
For developers making software for handsets, this isn't terribly interesting. However, if you want to prepare your software to run on some of the first Android netbooks, this could be a great way to start limited testing, especially when it comes to larger screen sizes.
The wiki pages have lots of discussion about how to use it, what hardware works, how to configure the network, and how the various special keys are mapped. I highly recommend reading these pages before trying to use this.
Have fun running Android natively (or virtually) on your machine -- without the emulator.

Latest Android 1.5 SDK, Release 3, Fixes Emulator Defects


Have you missed the ability to call or SMS from one emulator instance to another? Have you be tearing your hair out over the hang when getting the SensorManager? Well, look no further than the third release of the Android 1.5 SDK. It fixes these issues, and more.
Download it from the usual SDK site: http://developer.android.com/sdk/
Read more about the fixes in the release notes.

Jumat, 26 Juni 2009

Scripting on Android


Did you know you could script for Android? With Python, Lua, and more languages coming? And not just for Android, either... but on Android devices?
Well, you can. A couple of weeks back, the Android Scripting Environment project was discussed and downloads are available now for alpha versions of this application. One frequently cited example as a Lua script that, in under 20 lines of code, allows the phone to be silenced -- or not -- by just flipping it over.
Check out the Android Scripting Environment now for some on-the-go scripting fun!

The Android NDK 1.5 Release 1

Google announced that the Android 1.5 NDK Release 1 is available. No, this isn't another SDK. Instead, it's the Native Development Toolkit, which basically allows developers to use C or C++ for development -- with a whole bunch of limitations.
The gist of the goal of the NDK is to provide a way for CPU-intensive operations to be implemented outside of the Dalvik virtual machine to increase performance. The libraries available are limited and it's not designed to allow development of entire applications using native code.
Read more about it at the Android Developer site.

Kamis, 11 Juni 2009

Choosing an XML Parser for Android

When new versions of the Android SDK come out, I often like to peruse the more detailed changes. A while back, I ran across mention of including the XmlPullParser API for enhanced mobile XML parsing performance. Busy at the time, I didn't do much with it. The curiousity ultimately got the better of me and the result is an article on the XML parser performance comparing the SAX, DOM, and Pull Parser performance on Android. Feedback is welcome via the email address listed at the article.
ANDROID BOOK © 2008 Template by:
SkinCorner