Header Ads

Sample Android Application - Designing and Developing an Android Application

Its been a very long time since my last blog post. I have been held up with multiple things and now I got the mind to write a post about my experience with Android application development.

Android needs no introduction. Every one of two smartphones used nowadays are powered by android(In India at least).There are lot of apps in the android market, many of which are just awesome. My desire to write Android app dates back to 2010 when I was in final year of Engineering, there had been many starts, but stopped abruptly due to various reasons(laziness being one of the main reasonSmile with tongue out). This time I started and I was able do a considerable part of application.

App Name FullScreen Photo Caller ID
Idea Rip off from here.
Motivation The free version of the above app can be used to set contact pictures for up to 5 users. And the paid version costs around Rs.250 which is very high and I’m sure very less people will buy. So, I thought to write an app an provide for free.

Thought the app I wrote is having very less capabilities compared to the above one, but provides the important one, displays a full screen photo when a contact calls. So in this post I am going to explain how I went about developing this application.

Idea is simple, a corresponding picture should be displayed in full screen when a contact calls. Many things were to be considered in the design stage:

  1. To start my application when a call event takes place.
  2. To disable the default key guard in the phone.
  3. To allow user to select a picture for a contact.
  4. To display that particular picture while a call event takes place.
  5. Provide call accept and reject functionality (most tougher part).

I had very less idea on developing an application. But the android developers website along with the ADT plugin for eclipse make life easier for any app developer. Read this page for installing SDK, this for hello world tutorial and this for notepad tutorial. Notepad tutorial contains 3 examples, completing this will give us a better grip over Android fundamentals.

In android system, any class should extends the Activity class. Activity class maintains the state of the application, oncreate, onresume, onpause functions can be overridden in our application to the make the state of app sync across different events that takes place in android.

Now to the application I am writing. Point 1 written above can be done by extending a BroadcastReceiver class. It tells the state of the phone (ringing or idle, etc.) and we can override the different functions to do corresponding work. Unlocking the keyguard can be done with the help of KeyguardManager class.

Point 3 and 4 are done writing an activity for storing the details in the database and displaying images by querying the database. Coming to the most difficult part according to me. Making the call accept and reject. Google doesn’t provide a direct method/API for attending or rejecting a call. I googled (as anybody does Open-mouthed smile), and found many ideas of implementing this. Everyone provided a round about way and I took one of the ideas, where an intent is sent to trigger button events and enable the headset programmatically and attend the call. Reject was far more worst. Google provided with less results and one implementation was to use a class that is only internal to android. One of the Samsung developers posted this on a blog which uses Java’s reflection and this is the only one method that will work (Requires MODIFY_PHONE_STATE permision). But this hack will not work in Android 2.3 and above because Google has made the MODIFY_PHONE_STATE permission is required unavailable for use by normal third party apps.

So the app I have written well for phones with Android < 2.2 (Tested with Samsung Galaxy Ace and Galaxy 3) for phones with 2.3 and above accept calls work (tested with Samsung Galaxy R and LG Optimus), for rejecting calls, just press back button when contact picture is displayed and then ordinary call even screen will be displayed.

Here are few screenshots from App. I will post the link for downloading app soon and also will post the code in code.google.com or github as open source so any one can contribute Smile.

FedererRajiniSachinSchumi

Thanks a lot for reading this. Please post your ideas and comments about my app and idea and this post below.

No comments:


Powered by Blogger.