Showing posts with label api. Show all posts
Showing posts with label api. Show all posts

2009-07-08

HTC Dream's notification LED color.

Android documentation says:

public int ledARGB

The color of the led. The hardware will do its best approximation.

Best approximation my ass. I wanted #fb2a0c, I got pink. To get the orange color, I needed #080800, for which orange is most certainly not what I'd call best approximation. It seems that Dreams' drivers just feed the raw RGB values to the hardware without bothering to do any processing on them.

To make it easier to find out which color to feed your device to get the real best approximation of color you want, I made this quick and dirty android LED tester. Just slide the sliders until you're satisfied, note the values and get on with it.

As a note, you might want to only serve the fake colors to devices you tested them on, in case other devices handle this properly and your app would turn out to blink the LED in real #080800, which is to say, almost black. I do this with if (Build.DEVICE.equals("dream")) color = 0xff080800; else color = 0xfffb2a0c; obviously if you test on more devices and they're all equally quirky, you need to add more checks.

2009-06-28

SIM contact list query doesn't support filtering

content://sim/adn doesn't respect the where clause when querying it. Just so that someone doesn't spend as much time wondering why the freaking thing wouldn't work as I did.

You have to filter it another way. I did by creating a custom CursorAdapter to filter it, but your mileage may vary. It might be better to make a cursor wrapper, or something. Or is there something like that in the library already, and I just missed it?

2009-06-23

Launching applications in Android

To launch an application programmatically in Android given an ApplicationInfo, do:

ApplicationInfo ai;
PackageManager pm = getPackageManager();
try {
    Intent i = pm.getLaunchIntentForPackage(ai.packageName);
    startActivity(i);
} catch (Exception e) {
    Toast t = Toast.makeText(this, "Couldn't launch the application.", Toast.LENGTH_SHORT);
    t.show();
}

Apparently this was harder pre-1.5, where you had to look for the proper activity yourself.