Archive for the ‘Android’ Category

Android: Getting ARGB from a JPEG

Thursday, January 15th, 2009

With J2ME, “Opening” a JPEG into an ARGB array may look like:

Image jpegImage = Image.createImage( jpegByteArray, 0, arrayLength );
if (jpegImage == null) {
//ERROR
} else {
jpegImage.getRGB (argbArray, 0, jpegWidth, 0, 0, jpegWidth, jpegHeight);
}

Since Android does not have an Image class, the following code will produce the same results (Please note the similar API):

Bitmap jpegBitmap = BitmapFactory.decodeByteArray(jpegByteArray, 0, arrayLength);
if (jpegBitmap == null) {
//ERROR
} else {
decodedBitmap.getPixels(argbArray, 0, jpegWidth, 0, 0, jpegWidth, jpegHeight);
}

Not that different, isn’t it?

(And I know I need a better blockquote for code… working on it)

Android Activity and Networking

Wednesday, January 14th, 2009

Google has selected a new model for the Android User Interface: The Activity, which is tied to User-Interface.

Now, when someone (like me) intends to implement a UI with someĀ  networking threads and processing, the two options are:

1) Running the Networking as a Service

2) Spawaning threads from the UI activity.

The two options are not that bad, it is just that using a Service model is an overkill for most applications, and having one activity which manages everything – UI as well as tasks seems like the easier solution.

When I started, I assumed an Activity can be anything, but as clearly stated:

(an activity that is not visible to the user and has been paused) is no longer critical, so the system may safely kill its process to reclaim memory for other foreground or visible processes

Sorry for not posting code, but this project is not an Open Source.

Android Rules!

Thursday, January 8th, 2009

As more and more Android news are added every day:

1) SkypeLite for Android

2) Windriver showcases Android on Qualcomm’s Snapdragon (What a strange name, isn’t it).

And as I am gaining more experience with the Anroid OS and Application API, I am convinced Android is THE next OS for Cellular phones and MIDs! Not even one doubt in my mind.

Symbian

Became a very strong player in the Cellular phone business, but had no plan going into the MIDs. Symbian is not bad, but the new OS (iPhone and Android) are more “sexy”, and I will not be surprised if number of application developed for iPhone and Anroid already surpassed the number of Applications developed for Symbian.

Linux for Mobile Devices

There are a few examples, but too few.

Windows mobile

Will keep the Market share in the next year or so, just to see Anroid getting stronger.

iPhone

It is nice, but the API is closed, and what appeals to me and MID vendors is the opennes and how easy it was to port the Android to other platforms.

Are you convinced?

Android network access and documentation

Sunday, January 4th, 2009

I have spent around 5 hours trying to understand why opening a simple Socket return an “unknown Error” exception.

A quick search (after the 5 hours) has proved very helpful, as it turns out there is a permission system in Android which should be defined for each Activity/Application.

So, if I need Internet access in my activity, I should clearly state that:

<uses-permission
android:name=”android.permission.INTERNET” />

The only problem it doesn’t work… so I am still searching for some CLEAR documentation on how to do it.

Google – Please properly document your product. Please put in Java.net.Socket documentation some kind of warning or link to permission information.

Well… I should also read the Security model more carefully (but who really does that?)

Android SDK and application development

Tuesday, December 30th, 2008

After toying around with the Android Platform and browsing through the Linux Kernel code, I have realized that not having an actual phone will block me from experimenting, so I am postponing this activity.

In the meantime, I am migrating a mobile application (will reveal which one at a later date) to Android. The guys who wrote the application did a wonderful job trying to stay as generic (Java) as possible, thus relying less on J2ME WTK implementations.

But still, Anroid activity is not a midlet, the life cycle of an activity is different as well as drawing primitives and more.
Will report about these efforts and progress.