We're Off to See the Market

Illustration

In order to put application on Android Market one of most important steps is signing it. There is pretty comprehensive guide available for that in developer documentation. I followed instructions wondering why everything needs to be done in command-line only to discover at the very end that those steps are not needed.

All you need is proper setup of your development environment. Once you have that, creating Market-ready application is just matter of right-clicking on project and selecting “Export Android Application”. From there wizard will guide you through key creation, compilation and all other necessary steps.

I'm on the Market

Illustration

My first Android applications are out in-the-wild.

I will list them here:

  • Poštanski broj will allow you to search through all places in Croatia in order to find their post number, geographic location or just to view map of their surrounding.
  • Praznik will give you overview which holiday comes next in Croatia.
  • Rođoš makes use of existing birthday field in contacts and shows them all in one place.

As you might guess, user interface is in Croatian. Fortunately all applications are quite simple so usage for non-Croatian speakers should also be possible. English version might come in future but that highly depends on my free time.

Retrieving Application Icon in WPF

As I started doing more and more work in WPF, I had to port my “About” dialog. In attempt to keep everything clean of Windows Forms that also meant that I need to find another way of loading icon (since Bitmap class is not part of WPF).

Code follows same logic as one for Windows Forms. Only important difference is use of ImageSource as our final destination.

var hLibrary = NativeMethods.LoadLibrary(Assembly.GetEntryAssembly().Location);
if (hLibrary != IntPtr.Zero) {
    var hIcon = NativeMethods.LoadIcon(hLibrary, "#32512");
    if (hIcon != IntPtr.Zero) {
        return Imaging.CreateBitmapSourceFromHIcon(hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
    }
}

Without further ado, here is full sample.

The Image Format Is Unrecognized

Illustration

As I started my new WPF application, I got greeted with FileFormatException - “The image format is unrecognized”. I was confused since application was so new that I haven’t added any images to it. After checking and double-checking I found which image exception was referring to - my application icon.

It seemed like normal icon to me. As I compared it to icons that I already used successfully with WPF there was only one difference. This icon had 256x256 size. As soon as I deleted it, my program started working again (ok, it was empty application so making it work was not that big of task).

Side effect of this solution was that I lost my big images. That felt dirty to me so I ended up with two icons in my application. First one was with all images (including 256x256) and I used it as application icon (Properties, Application, Icon). Second one was without 256x256 images and I just set it’s Build Action to “Resource”. Whenever I needed WPF window icon, I just pointed to second one.

I must confess that I am quite annoyed by this. WPF was all about making Windows look and feel better. Using brand new .NET 4 and restricting icons to sizes before Vista just does not seem right. And I better not start about how useful XAML exceptions are…

P.S. If you do not have icon editor available, I would recommend IcoFx. It is good and it is free.