Category Archives: Uncategorized

Today we’ll create an Android application that can calculate Prayer Times for muslims. If you integrate location API with this application to retrieve user location then, it can be used anywhere in the world. The application takes care of the timezone automatically.

Create a cool UI for the application and feel free to use my source code and don’t forget to give me the feedback regarding accuracy.

During my training sessions, trainers frequently ask few questions. Also I get a lot of requests to provide useful links on various features in Android platform. Although developer site is good enough and there is stackoverflow and github to get solutions, I think it will be helpful to many if they get some good links here.

1. LazyList: Creating Custom ListView with Lazy Loading:

Often you’ll need to show a big list in ListView with image icons which are supposed to be downloaded from any server. The problem is you can’t wait to get all images downloaded and then show the listview with data. This project in github solves this problem by asynchronous loading of images. Another great thing is that it supports caching of the images. Caching is down by saving those images in SDCard.

These 2 blogposts discusses various use-case scenarios regarding the use of Location API GPS data in Android. They thoroughly discuss the accuracy issues along with which way to choose during development based on application requirements. The posts are very detailed and great.

Although the following blogposts do not describe “Best Practices”, but they are a good starting point to create web services in PHP(with MySQL) and connect from Android applications. They include source codes and explanation.

We keep the layout simple by keeping
i. a button to start reading
ii. a button to stop reading and show graph
iii. a button to upload data to server (covered in next post)
iv. a placeholder in the below portion [LinearLayout] as the chart container

Layout

3. MainActivity.java

First, to listen click events to the buttons and to listen to the SensorEvents we implement the Activity as SensorEventListener and OnClickListener (android.view.View):

SensorManager lets you access the device’s sensors. Get an instance of this class by calling Context.getSystemService() with the argument SENSOR_SERVICE. [http://developer.android.com/reference/android/hardware/SensorManager.html]

Always make sure to disable sensors you don’t need, especially when your activity is paused. Failing to do so can drain the battery in just a few hours. Note that the system will not disable sensors automatically when the screen turns off.