Android: Notification Icons

The Android notification bar has been white for a very long time. A great many apps that put up icons inside this bar create black icons with transparencies so they appear black on white when viewed against this white notification bar. Unfortunately, with Android 2.3.3+ and 3.0+, the notification bar is now black. Black icons on black bars do not show up well at all.

I highly advise against creating separate icons for the different versions and instead offer the tip of creating a white background for your black icons. In my apps that require a notification icon, I gave the icons a round, white background that used the alpha channel to fade the white from the center to the edge. The effect is that on the older, white notification bars, no difference is detected since white fading into white is the same thing as nothing at all. On a black background, however, the effect is that my black icon is visible within a white circle that fades to black, making it look like a modern, 3D rounded icon.

Example Notification Icon

Personally, I detest the current state of my 2.3.4 phone’s notification colors since most of the apps currently use black or dark grey notification icons (including stock apps) and as such makes it nearly impossible to see them at a glance when checking my phone for messages out in bright daylight. Whomever’s bright idea it was to push this change out to phones that have been using and expecting white notification bars for years now should be given a painful wedgie!

Picking a Contact photo with Motorola Cliq

Some Motorola Cliq phones are having issues trying to pick a contact photo using something other than the Gallery app that comes with the phone. Motorola is aware of the issue, but I am trying out a workaround for it in my File Browser app. Basically, the problem is that an OutOfMemoryError could result from attempting to pick a large photo because the Intent being used does not specify the size to be returned. Normally, I would just use getIntExtra(“outputX”,defX) and getIntExtra(“outputY”,defY) in order to get what the caller wanted as a size, but since Motorola’s contact app does not provide those Intent Extras, it would return the full sized photo.

Instead of waiting for Motorola to modify their app, I decided to check the name of the caller and provide a default size for that particular app.

if (myActivity.getCallingPackage().equals("com.motorola.blur.contacts")) {
    outputX = outputY = 48;
}

Android Market vs. Drawable XML

Android drawable resources include the ability to provide and XML resource that specifies a different name for it’s bitmap resource.  It is an especially handy mechanism for library code to refer to a specific drawable resource that your app provides under a different name.

For example a drawable xml named “app_icon.xml” could contain:

<!--?xml version="1.0" encoding="utf-8"?-->
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/ic_MyAppName"
/>

If you used this kind of resource as your application’s icon resource inside your AndroidManifest.xml file, though, you have a problem. While technically, the app will function normally, the Android Market tries to check to make sure your app’s icon meets some guideline criteria and cannot handle an XML drawable. Android Market will refuse to upload your app and tell you “The icon for your application is not valid. Please use a 48×48 PNG.”

If you use XML drawables, please keep this limitation in mind and do not reference them inside your AndroidManifest.xml.

Android Market does not allow use of Android icons

If you tried to publish your app to the Android Market and received an error similar to the following one, you may be running up against a block put in place by Google:

The file is invalid: W/ResourceType(15353): No known package when getting value for resource number 0x01080049 ERROR getting ‘android:icon’ attribute: attribute is not a string value

I recently ran into this error trying to publish one of my apps because the icon I chose for my app’s Preferences screen activity was a built in android resource “@android:drawable/ic_menu_preferences”. Continue reading