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
Category Archives: Tips & Tricks
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
Gesture Detection (swipe detection)
Simple swipe detection. I know this example code has been done elsewhere, but I wanted it here for my own purposes as well. The example code uses a ListActivity and places the listener where it needs to go in order to detect swipes on the list. Continue reading
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
Get Android phone settings with ADB
A useful debugging tool, especially if you have several emulators in various states like I do, is to list all the phone settings that are stored in Settings.System and Settings.Secure as well as their current values.
$ adb shell #sqlite3 /data/data/com.android.providers.settings/databases/settings.db sqlite> select * from system; sqlite> select * from secure;
Settings that once were in System migrate to Secure as Android versions get released, so it is sometimes handy to know exactly what state the phone is in while you’re debugging on it.
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
FileBrowser Send / Receive Intents
Blackmoon File Browser app has grown from a simple browser to a full fledged file manager and able to launch apps based on the given file name so that you don’t have to launch the app and then open the file. Expanding on this idea, FileBrowser grew arms with which to pass off data to other apps in singles or multiples. FileBrowser then grew ears to listen for other apps that wish to use it’s functionality to pick files or folders. Most of these Intents are discoverable, but any good dev knows that getting information directly from the source trumps whatever else is available. In this article, I will specify what Intents FileBrowser uses and how you can use them in your own app. Continue reading
Handling “Browse for Folder” intents
If you are an Android app developer interested in responding to a “pick folder” intent, this article is for you. There is no strict definition on how to respond to intents and so one must follow published guidelines from the author of each app. Continue reading
Android: Always create a Launcher activity!
ALWAYS CREATE A LAUNCHER ACTIVITY!
I cannot stress that enough. When I created AttachSave, I designed it with the intention that it would be a small, hidden app that did not clutter up the launcher tray with useless apps that couldn’t be run traditionally anyway. Despite warnings from others posted elsewhere, I thought making the description quite clear on how to use the app would be sufficient to teach people on how to use the app. Continue reading