Android developers are being asked to build proper app for the Android platform. You surely might have heard about the battery backup issues on Android devices. This is the reason, several sessions were made at Google I/O 2010 to let the developers know how to make better apps by avoiding these:

1) SLOTH:
Th key to make the best applications on Android. Fast & Responsive.
The Golden Rules Of Performance
Don’t do work that you don’t need to do
Don’t allocate memory if you can avoid it
Responsiveness
The application should’t make user to wait, Android device is a mobile device where the user expect responses pretty faster than the PC which is kept on the desk and the user sits infront waiting for things to happen. So no modal loading on mobile devices because user use the device on the go!
You’ve a five seconds to response to user on user’s action, if not then your app fails right there. To avoid this, you need to process the request of the user in background, in another thread so that the UI thread be active and doesn’t runs into unresponsive mode. We usually do this using Java’s traditional Threads through making UI Thread separate and other for processing the request in background and both need to get sync as each thread experience any change, but Android has it’s own Class which takes care of it right away and reduces this huge lines of code in your source code. This Class is called “Async Task”, the following is the sample code:


protected void doInBackground(Void… arg0) {
//Do your time consuming process..
publishProgress();
return null;
}
protected void onProgressUpdate(Void… arg0){
}
protected void onPostExecute(Void result){
}

2)GLUTTONY
The only worse thing than having the app that is slow and unresponsive, is an app which makes the system slow and unresponsive and drains all of your battery as well. The key is to always use the system resources in responsibly. So, to avoid being a bad developer all you want to do is make sure you are being very respectful of power. Don’t use power until you absolutely have to. Don’t do updates too often than you need to, either. The followings are Don’ts and Dos:
Don’ts
Don’t’ use over WakeLocks
Don’t update Widgets too freequestly
Don’t’ update your location unnecessarily
Don’t use Services to try to override users or the system
Dos
DO share data to minimize duplication
DO use Receivers and Alarms not Services and Threads
DO let users manage updates
DO minimize resource contention
What is WakeLock?
-It force the CPU to keep running
-It force the screen to stay on (or stay bright)
-It Drains your battery quickly and efficiently

PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Wakelock");

Do you really need to use one?
Use the minimum level possible and consider which property is suitable for your need,


PARTIAL_WAKE_LOCK

SCREEN_DIM_WAKE_LOCK

SCREEN_BRIGHT_WAKE_LOCK

FULL_WAKE_LOCK

  • Release as soon as you can
  • Specify a timeout
  • Don’t use them in Activities, instead use them in Window


wl.acquire(10000);
//Screen and power stays on
wl.release();

3)HOSTILITY
Don’t make user pull out the battery out of their devices.. Don’t drain the power.
“Doing what the user aspects with respect to navigation flow is absurdly important for overall user satisfaction.”
  • -User experience should be your top priority
  • -Respect user expectations for navigating your app
  • -The back button should always navigate back through previously seen screens
  • -Always support trackball navigation
  • -Understand your navigation when try point is o notification or widget
  • -Navigating between application elements should be easy and intuitive
  • -Don’t hijack the native experience
  • -Don’t hide the status bar
  • -Back button should always navigate through previous screens
  • -Use native icons consistently
  • -Don’t override the menu button
  • -Put menu options behind the menu button
  • -Respect user preferences
  • -Use only enabled location-based services
  • -Ask permission before transmitting location data
  • -Only transfer data in the background if user enables


ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
boolean backgroundEnabled = cm.getBackgroundDataSetting();

4)ARROGANCE
  • -Don’t fight with System, mean don’t use unofficial documented APIs
  • -Undocumented APIs will gonna be breached by Google in next update. Think about it before using it.
  • -Make your app behave consistently with the system
  • -Respect the application lifecycle model: on pour on start. saving data saving cache
5)DISCRIMINATION



There are just so many architectures that Android OS supports, that easily can’t be guessed. Android OS supports almost all the major hardware architecture. If you taget at any one type of device you might miss the 2/3 of market. Try centralizing resources, like images and strings, etc. that will help you maintain the resources for all different devices available ion market. It also helps in Internationalizing your application.

Flash 10.1 Beta for Android 2.2 Froyo is now available at Android Market. There was a huge buzz since the beginning of this year that Android will have a complete Flash support.

As we covered most of the flash news earlier, regarding its support to Android and also from development perspective it is pretty evident that Flash developers now have an opportunity to reach out to a huge Android market.

Flash 10.1 for Android is almost the same as Flash 10.1 for PC / Mac. We thought that this is going to enable developers to easily target the same PC / Mac Flash code to Android devices, however this is not what Adobe and Google want the developers to do. According to Google, the Flash content should be separately optimized for the mobile devices for better user experience.

I was expecting that an Android device can seamlessly consume the Flash content; though this is very much possible to consume, it’s been advice not to. Every Flash content site’s admin / webmaster are happy that they finally can reach out to users, right to their handheld without getting major changes to their sites. Earlier they were having only one choice and that was to get rid of flash to reach out the huge mobile audience but now they seems to be happy to go ahead and do some minor changes to their sites. Getting any sort of tweaks to heavy Flash content sites is not that easy at all. Every Flash developer knew how hard it is to change the view part of it, that too keeping the same view for the mobile devices. If the developers decide not to tweak existing one and come up with a totally new site then it’s the same as getting rid of Flash based sites for their mobile audience (development perspective), which doesn’t make any sense.

Well, for now you can view almost all the existing content on web with the risk of the device getting too sluggish and that’s the reason Google is asking developers to optimize sites specifically for mobile devices.

Anyway, Flash developers have already got an huge heads up from Google in terms of the exposure to the huge handheld market that Google has offered them with Flash on Andorid.

Android 2.2 is being previewed at Google I/O. While most Android developers and users are eagerly waiting for news on Flash on Android 2.2 Froyo news we will first cover some  of the other major changes to the OS that is going to make Android 2.2 Froyo a dream expereince for android developers to work with. We will definitely update you with Flash on Android news in a later post.

These updates seems to be major ones listed on Android’s official site. As we posted earlier that Android 2.2 Froyo is 420 times faster than the Android 2.1 Eclair. These updates basically shows ‘how’. And as an Android developer you have every right to be excited because these updates doesn’t only explain why Froyo is faster but it also has the potential to enable developers to serve the best UX(user Experience) for their Android applications.

1. Dalvik VM : Just-In-Time (JIT) Compiler = 2-5X faster performance.

This is the virtual machine which has brought changes to Android OS with 2-5X faster JIT(Just in Time) Compiler, which basically means that your code, whenever it’s executed as an activity or service or broadcast receiver, it’s converted on the fly and make each process run independently. This process of compiling third party code on the go (is called on-the-fly) is much faster than the previous versions of Android.

2. APIs & Services

⁃ Cloud to Device Messaging

This was one amongst the most needed feature on Android. This is basically like iPhone’s Push Notification for Android, in fact a little beyond that. If you’re an Android user, you must know that there are just too many notifications that await for your response in notification area. So, this one is quiet like, whenever you need your app to load up without any user’s input, then this is the brilliant way of doing that. Imagine, you receiving an email and instead of just listening the alert you might see the Email client already loaded up on screen showing your email without any user input.

Your Android device has a seamless connection with the cloud. Whenever the cloud experience the change with it’s message stack it pushes those messages to the device. And when the OS receives the change from cloud, it automatically loads up an appropriate app to view this message.

Another most known implementation of this Client to Cloud Messaging is to use as push notification services. In which the App never runs in background but user will receive update for that app, which makes the platform more robust and stable because less app in memory reduces the CPU cycles and hence no battery drain.

⁃ Application Backup API

This is the new Data Storage API through which you can help users to backup their Data in ‘cloud’. If you’re developing an app which deals with vital user information and the user forgot to back up that data and formatted the device, he / she probably has lost their vital info. So, here is where this API helps developer to develop an app which takes care of the user data to be backed up in the cloud. Whenever they change the info in the app, that gets updated in the cloud and this data is can be restored as well. So, if the user deleted that app or restored device or formatted, if the app backed up data earlier, then this data can be restored back to app without any issue!

⁃ Apps on SD Card

This is the feature required on  devices which has lesser on-device-memory and uses expandable flash memory. So, if the user decided to save more memory on device, he / she would actually install app on SD card. In earlier OS versions, you basically need to replace the app through copy / pasting it into SD card but through Froyo update you will actually able to select where to install the app when you’re installing from Market.

⁃ Portable HotSpot

This is the magical feature on Android. Whereas, on other platforms you need to download third party app to get such feature. Portable HotSpot is nothing but turning your Android device into WiFi access point. Isn’t it great? Turning your device into access point makes your device more useful if you have only one option left on your Laptop and that is Wifi.

3. Browser V8 = 2-3X faster javascript rendering

Android 2.2 Froyo is said to have the fastest mobile browser. As you might have heard that Google’ new Chrome gonna be the world’s fastest browser too. Google introduces the new V8 JavaScript rendering engine which is embedded in Froyo’s Browser and also on Google’s new Chrome.

V8 is built on C++ and  implements ECMAScript as specified in ECMA-262, 3rd edition and runs Windows XP and Vista, Mac OS X 10.5 (Leopard), and Linux systems that use IA-32 or ARM processors. It can be run standalone or can be embedded into any C++ application.

4. Android Market

⁃ Auto Update and Update All

You have an option in Android Market in Froyo to Auto Update your already downloaded app. You can set this settings in Market app. This update is only possible until any permission given to the app is unchanged. However, if the app needs new permission to be granted, then the device needed a user input through little info on what all new permissions is been changed.

⁃ Application Error Report

In Froyo, Android developers gonna receive the Error Log generated by the Android device. This feature gonna help developers a lot to get the best user experience to the user device. Developers gonna receive this Error Log in their developer account at Android’s official’s site.

The above are the major changes brought to Android 2.2 Froyo. We’ll keep updating to you as we get to know more about this latest update.

Adobe confirmed that the Flash 10.1 Beta for Android will be available later this year and has published a sign up page to get notified upon availability. As we posted earlier that Flash Developers Can Now Step Into Android Development, I think that day is not that far.

A prerelease version of Flash 10.1 is already available for Windows, Macintosh, Linux & Solaris Operating Systems & it will be available for mobile platforms later this year. Flash on Android can make a big change to the platform itself and can initiate a lot of changes in the way Android development is done this days. Thousands of Flash developers are just waiting for this opportunity.

The best part of it is, developers now no longer need to write separate code from scratch to target their content to Android user. The same code which they’ve written for desktop browsers can be consumed by the Android users, through Chrome. So, what are you thinking? Facebook Apps? Yeah! Once Flash hits Android, Facebook game developers would have a great opportunity to drive mobile traffic to their content and also to the Facebook platform. If you’re already a Facebook App developer and develop on Flash, then here is already a great news for you.

Do you think Android developers would love this change? This is sure to bring in a lot many apps to the Android platform but as an Android developer, do you think it would make the market more competitive, with flash developers biting into your pie ? Share your view in comments.

HostGator.com for easy WordPress hosting