Recently - as I bought a Google Nexus S some time ago - I started taking a look into development of applications for the Android platform. After some experiments with the general hardware features like the accelerometer and others, I have implemented a class that may be useful for others, too.
One thing I like on the Nexus is the "Car Home" app made by Google. While driving, it provides you a very simple interface with large buttons in order to trigger different actions. Although you can create shortcuts with it, I thought it might be even better if you could have this launcher menu in the app itself that your are developing.
Based on this, I have implemented a class that you can inherit in your project in order to have a "Car Home"-like launcher menu, as you can see in the image on the right. The usage of the class is extremely simple. It is working with API Level 5 upwards.
How to use my LauncherActivity
- Download the necessary files (link at the bottom of this post)
- Extract the contents in your project folder
/src/LauncherActivity.javato the folder of the package where your other source files are located (e.g.
LauncherActivity.javaand change the package name in the first line to your package name
- Let the activity which shall display the launcher menu extend from the LauncherActivity class.
- (optional, but recommended) override the methods
onLongClick()with your custom code (see documentation for details)
Optionally, in your
AndroidManifest.xml, add the following line to the Activity you have created:
This ensures that the animation while launching the activity is displayed correctly.
Every part of this implementation is documented. The documentation can be found inside the
/doc folder of the extracted archive. As everything important is explained in it, make sure to read the documentation ;-).
If you find a bug or have any questions regarding this class, just send me a mail! Finally, here is a short video presenting the behaviour of the launcher menu: