Friday, December 7, 2012

Tips and tricks for smarter development

Here is a compilation of the handy tips and tricks that i come across while developing for Android.The list is expected to grow with time and you can always post a comment to get something added to it :)

1. Go wireless

Install ADBwireless from playstore on your device and press the "Big Button" to enable wireless degubbing. Change to the platform-tools folder of the android-sdk and type the following command:
./adb connect
Check for the device in the eclipse DDMS perspective and use it just like a normal connected device. Unfortunately it works on for rooted devices.

2. Have a memory management activity

The "Clear Data" button present by default in the "Manage Applications" clears the database and shared preferences for the application.If you do not want the users to clear all the data then this option can be overridden by adding a custom space-management activity in the application. Add the following line to Application tag:


3. Let the user choose install location

In the Android manifest file add the following line to the manifest tag and set the location of app installation. I always choose preferExternal so that apps can be moved to sd card, but that might not be a wise choice for game developers.


4.  Not Enough space to install the application!

Do you really need to remove applications to install new ones? No you don't! Connect the device to adb and run the following command and install as many apps you want on the sdcard.

 ./adb shell pm setInstallLocation 2

5. Save time writing parsers , use Gson

 If you need to parse JSON responses from web services, you can save a lot of time by using Gson API. It is an android compatible JSON parser which parses the response and populates the beans with just tow lines of code!

6. Surprise!

Go to phone Settings > About phone  and tap multiple times on the Firmware version option.