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: 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

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

Swidget released to the public

A friend of mine was very interested in a pet project I had started a while ago when I got sick of having no compact version of Google’s switch bar available. The Market only has single toggle widgets and Google’s built in widget is quite large. I don’t toggle all those switches often enough for something like that to be useful.

After several stops and starts, I finally settled on something I could not only live with, but it is something that replaces several widgets on my phone, freeing up a lot of room for something more valuable like a memo widget, clock, pic, app shortcut, etc. etc. etc. My idea was to create a 1×1 cell widget that popped up with several toggle switches after pressing it. By doing so, it allowed for several to be grouped up together into one tiny package. The amount of “clicks” increases by one, and that will put off some people, I’m sure, but I don’t care so much for adding a click if it saves me a ton of room on my Home screen(s).

My friend also suggested I make some of the switches auto-enable themselves if the phone got plugged in as well as turning them back off once you go back on battery. I have found that plugging/unplugging the phone is usually the reason I toggle anything in the first place, so that seemed like quite a handy feature to implement.

I found the challenge to create Swidget quite enjoyable and am pleased with the outcome. I decided that there may be others like my friend and I who would like the option of a compact set of switches rather than a large set of individual ones taking up valuable Home screen real estate. Swidget is now available in the Android Market, AndAppStore, and SlideME for only $1.49.

Enjoy and take care!

Pick Folder Intent

One of the powerful features about Android vs other mobile operating systems is the ability to create and Intent and ask the system if there are other activities that might be able to respond, even if they are in some other app. Why reinvent the wheel with every app if there is already one much more capable already out there? By apps working together, we can create an ecosystem of apps that inter-operate without requiring explicit code shared between them. Intents are powerful in that they are open ended and can carry a vast array of data and filters between apps. However, since there is no strict definition on how to create intents for all kinds of purposes, one must follow published guidelines from the authors of apps or rely on a site like OpenIntents.org that register Intents so others may use them correctly. Continue reading