Android provides several mechanism to sense location of the device. It utilizes three main sources in order to learn location, i.e. GPS, Wi-Fi and Cell Tower. Last two are grouped into Network category under the Android documentation. Accuracy of GPS can be up to 5-10 meters in an open sky environment. GPS is known to have some problems especially in indoor conditions, hence other mechanism need to be exploited in order to learn location more precisely (Google is known to work on indoor mapping). Wi-Fi and Cell Towers are among the alternative tools one can use to learn location. Especially, Cell Tower could be very useful especially for the application which needs coarse-grained location information to work (most applications can fit into this category). Another advantage of using cell tower is its availability: mobile devices are always connected to network, i.e. location information is already available. Also note that smartphones are known to be battery hungry, so instead of opening GPS up, using already available information one can preserve a lot of battery. Here the downside comes: in order Cell Tower location to be accurate enough (1-2 km), it needs to be supported by a method called triangulation. However, to my surprise, sometimes, if cell tower changes (even when you're not moving), location can also changes dramatically (the circle can show you somewhere where you actually not). You can try this out by turning off GPS, Wi-Fi and opening the Map application with 3G. Although it doesn't happen frequently, Android's cell tower information can actually be tempting if your application depends on this crucial information.
After a lot of experimentation and exploration I ended up with the claim that Android fails to provide a nice and clean way of accessing location information. Although it seems to give developers freedom of choosing the source of learning, it doesn't give it as a uniform, power-aware way. Therefore, no wonder to see a lot of applications which drain user's battery carelessly. A lot of papers coming to alleviate this problem recently, citing one of them here.
[1] Improving Energy Efficiency of Location Sensing on Smartphones
Monday, January 16, 2012
Friday, January 13, 2012
Is it safe to rely on onDestroy() method of a Service
When running a service (either Service or IntentService doesn't matter), sometimes we need to wrap up things to degrade safely. For this, one can tempt to use onDestroy() method of the Service. However, keep in mind that this method is called by the System and it doesn't guarantee of calling in time: depends on several factors including the memory constraints. Therefore, one should not rely on this method to do critical wrap up operations, such as releasing a wake lock. Same argument is also valid for the Activity. More information can be found on the following links:
http://developer.android.com/guide/topics/fundamentals/services.html
http://developer.android.com/guide/topics/fundamentals.html
http://developer.android.com/guide/topics/fundamentals/services.html
http://developer.android.com/guide/topics/fundamentals.html
Subscribe to:
Comments (Atom)