Working with Android Libraries and shared code

One of the issues that has irked me for quite a while is the fact that there is no easy way to work with a set of shared code between apps in Eclipse that simultaneously gives me instant access to modifying the shared library and also the flexibility of including only the pieces of it that are needed while excluding the rest. Android Library Projects are a big step forward in helping to create a set of shared resources as well as code, but they still lack the flexibility of only including just what you need (not to mention Library Projects cannot use other Library Projects). Continue reading

Android 2.3 SDK and Formatted String Resources

The Android 2.3 SDK in Eclipse enforces the optional Argument Index if you use multiple arguments inside a string resource.

Still OK: 

1
"Hello %s."

Flagged as an error: 

1
"Hello $s, %d days have gone by."

Google is taking issue with implicit argument ordering on the grounds that it is not Best Practice to leave it up to the translators to place the argument specifiers if they need to shift around the order due to language grammar. While I feel that taking away Continue reading

Android: Update to Postmortem Reports via email

It has been a while since my post about Postmortem Reports via email and since then I have upgraded it, commented more on it and fixed a few issues as well. The class now protects against a null exception and uses the application label instead of the activity title in the subject. The class also unregisters itself on finalize as well as protects against sending multiple reports for a single exception if you have several activities active and each has their own handler registered. I am also happy to report that people are willing to send you debug reports. I do not receive more than a handful, but I only need one or two in order to figure out what is going on and fix it. I also can tell how serious it is depending on how frequently I get a report about it. I even get reports from people using a pirated version of my paid apps. Continue reading

File Browser Intents and Providers

I have finally put together a comprehensive list of Intents and Providers published by my File Browser app. You can find that list over on the File Browser Intents & Providers page.

As a convenience, I will post what is currently listed there:
Intent & Provider List

  1. Pick File
  2. Pick Multiple Files
  3. Pick Folder
  4. Save To New File
  5. Save To New Folder
  6. Playlist Creator
  7. Create Zip File
  8. Unpack Zip File
  9. MIME Type Provider

 

Using a SubMenu in a ListActivity’s Context Menu

One of the limitations of Android’s ListActivity’s Context Menu is that if your context menu gets too large to fit comfortably into one list, shortening it by putting several items into SubMenus requires special handling in onContextItemSelected().

Context menus, by definition, are transient and will be thrown away as soon as they disappear from view. Once you click on a MenuItem that displays a SubMenu, clicking any item in that SubMenu will call the onContextItemSelected(), as expected. What is not expected is that the standard call to get the MenuInfo will return null. Continue reading

Android app shortcuts and class names

I recently learned the hard way that refactoring your old code to be more consistent with how you write code now as opposed to how you wrote it a year ago can be dangerous. Things like class names may seem like a completely internal mechanism and is in most cases, but the rule for that changes the moment you place one into the AndroidManifest.xml. Continue reading

Do not install Widget apps onto the SD card

Apps like my Swidget, which are apps whose entire purpose is to provide a widget for your home screen, may have issues with being installed on the SD card. Android 2.2 introduced the ability to install apps to the SD card if the app allows it. This works great for many applications, but for some widget apps, it can be problematic. Continue reading

Avoid uncaught NullPointerException at Android app launch

While we all strive to avoid any kind of exceptions in software, we all make mistakes. One exception to be particularly mindful of is causing an uncaught NullPointerException during the app launch process on Android pre-2.2 (meaning the initial onCreate+onStart+onResume chain). The reason to avoid such a situation is that your app will crash, of course, but furthermore, the Android OS will notice that launching your app failed and will automatically try to launch it again — ad infinitum. Continue reading

Android String Resource XSL

I recently had a translator volunteer some time to translate one of my apps using MS Word on the strings.xml file. What I did not realize was that MS has a funny way of displaying XML files. MS Word will not display attributes by default, which means the name attribute is all but hidden from view. So instead of seeing the string:name attribute along with the string value that needs to be translated, all my volunteer could see was the string value. The name of the string could shed light on how that string was used in the app, so finding a way to present that information to my translator was a priority. Continue reading