Android View API inconsistency

January 25th, 2009

Have just noticed that View.invalidate API is different than View.postInvalidate.

If I understand this correctly, functions should be very similar as they have the same goal of invalidating the view or a region, so how come invalidate can accept a Rect while postInvalidate doesn’t?

SIP stack for Android

January 22nd, 2009

HSC has ported several communications stacks for Android:

  1. A SIP UA stack – MJSIP port
  2. RTP – jlibRTP port
  3. STUN – from jSTUN

Embedding SIP functionality into your Andoird application is now easier.

Link to HSC download page

First Android Application

January 22nd, 2009

Just completed my first project with Android Platform.

I ported Moblica‘s Snaptu application from J2ME to Android. The guys at Moblica did a great job keeping the interface as open as possible, thus the port to Android was not that difficult. Most of the challenge was to adapt the code to Android Model of activities and API.

The Android application is still in alpha, thus only selected users get to test it, but expect it in the Android Market soon.

In the meantime make sure you check out Snapu , these guys are good (and happen to be my friends).

Snaptu on Android

snaptu-weather

Opening a Browser from an Android application

January 20th, 2009

As always, there is more than one way to do it:

1) Easiest- by Embedding URLs in the application. In your TextView field, set the android:autolink to 0×01 (web).

2) Firing an Intent – startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))  – url is a String, and since startActivity is called, then obviously the context should be an Activity.

A comment on API changes: Google keeps changing the APIs, if you search Google Groups you may find a reference to ContentURI, now obsolete or other methods. So, keep looking till you find the most updated reference.

Android: Getting ARGB from a JPEG

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

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.

Japanese Open source

January 14th, 2009

I follow on twitter some Japanese bloggers, Open Source advocates, which allows me to get a glimpse to the Japanese Market. I found it sometimes amazing, how many original ideas are out there.

A few examples:

  1. twigadge – A twitter sidebar
  2. termtter – Command line twitter client, written in Ruby.
  3. nicodown – From the same guy who wrote 2, a C file that connects and downloads video from the Japanese Nico Nico Douga website. In his website you can locate a few more handy python, perl and ruby scripts as well as a development blog (Japanese)
  4. http://xa.yuiseki.net/ – Exteme Adhoc is the name of the website, and it is indeed extreme, you can follow schedule, twitts, locations, photos of several guys

Pidgin MSN update – Connected

January 12th, 2009

Pidgin has just managed to connect to the MSN network. I wonder if we will ever get an explanation what happened.

Android Progress

January 12th, 2009

The Android application is coming along nicely, networking works perfectly.
But! As I am migrating a J2ME application, I am having difficulties translating the J2ME design to the Android activities.
Will explain more once I decide

Pidgin update – Still doesn’t work

January 12th, 2009

Pidgin still cannot connect to MSN network.
Have tried to connected via a web browser, but apparently MS do not support the browser I am using (Firefox 3.0.5 on Ubuntu), and Meebo connected for a while, but after about 5 minutes disconnected claiming there was an error or I connected on another machine (yeah, I wish).