Showing posts with label GPS. Show all posts
Showing posts with label GPS. Show all posts

Wednesday, July 11, 2012

Location Finder - My first experience with Android

I started my career as a Java EE developer. Recently, my attention was drawn to the domain of hand-held devices. That was intriguing for me . Well, being a Java developer Android was a fine choice. 
I began by:
  • Learning the basics
  • Developing a project with Android
    • Define the boundaries of the project
    • Code and test
After spending some time on the basics I decided to get my hands dirty. My project is called Location Finder.

Objective:
  • Pinpointing all the points of interest in a radius given by the user on a map. Point of interest could be a specific keyword such as restaurant or a more broad one such as food which might include restaurants, confectioneries or etc.
  • All points of interest should be clickable. After clicking the overlaid icons, name and address of the place must be shown in a dialog box to the user.
So, my choice was a program capable of advising a user of nearest point of interest.

For this project I used 2 API's from Google. Google Map, Google Places and of course GPS on the device. There are so many good tutorials on how to integrate Google map into your code so I'm not going to delve in to that. I think this is sufficient to say that you have to sign up with the service and include a key in your View in order to use Google map services. That key is given by Google.

Business process is demonstrated below:
Diagram 1-Location finder activity diagram
  The diagram is created by Violet uml editor.

MainController class loads my main layout. It incorporates a very simple UI with one EditText,  a SeekBar and 2 TextViews acting as labels. Finally we have 2 Buttons (Find and Cancel). The design is depicted in the class diagram.


Diagram 2-Location finder class diagram

When the find button is clicked an Intent triggers the onCreate method of GMapActivity. The detail can be followed on the diagram 3 which is one possible sequence diagram of this application.
Diagram 3-Location finder sequence diagram

Source Code:

Monday, July 9, 2012

Android, emulator control is disabled under devices section of Dalvik Debug Monitor Server (DDMS) in eclipse

Problem :
Sometimes you can't communicate with your running emulator  although its up and running. There is nothing listed under "Devices" section of the DDMS view in eclipse. The "Location controls" section under Emulator control is also disabled. 

Why you need that ? For example, you want to have your location using GPS on your emulator. That can be achieved by simulating GPS coordinates using DDMS view > Emulator Control > Location Controls. There you can assign longitude and latitude.

Solution:
Try listing your running processes on your computer. On Mac you can use "Activity monitor". There you can find a process named "adb" (Android debug bridge). When you find it, kill the process and watch your eclipse console output for following message:

[2012-07-09 19:16:16 - DeviceMonitor] Connection attempts: 1

After few attempts you should have your connection to the emulator back. There should be an emulator listed under devices sections automatically.