Вы находитесь на странице: 1из 17

Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl...

Página 1 de 17

Mir

Mir Nauman Tahir. Development, Configurations, Tutorials and bla bla


bla ....

Android Google Maps Tutorial Part 2. Using GPS in


Android and Animating Google Maps to the Current
GPS location.
February 7, 2012 in Android Google Maps API Ver 1.0 | Tags: Android Google Maps API Ver 1.0, Animating Google Maps to Current
Location, Coordinates, DDMS, Emulator, GPS, Latitude, Longitude

19 Votes
In this tutorial we will make our way to get Coordinates from GPS. We will use the emulator, will learn how to
use the emulator and how to use the DDMS and how we can send coordinates from DDMS to our emulator. We
will start with a very basic application that will get coordinates from the GPS and will display it in a Toast. In
the second part of this tutorial we will use those coordinates and will make our Google Maps animate to that
location automatically. For using Google Maps Basics follow the link

http://mirnauman.wordpress.com/2012/01/30/using-google-maps-in-android-development-tutorial-part-1/

We will continue with the code in the above example, using the same API and AVD. First of all add the
following permission in the AndroidManifest.xml file, if its not been already added.

1 <uses-permission android:name="android.permission.INTERNET"/>
2 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
3 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Secondly check the AVD that is it with GPS support or not. As we can see in the hardware section that “GPS
Support” has a yes infront of it. Means GPS Support is installed.

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl... Página 2 de 17

Creating & Configuring New AVD

There will be no change in the “main.xml” file. Now open the “GoogleMapsActivity.java” file. Add the
following to the import section of the file. At the top.

1 import android.location.Location;
2 import android.location.LocationListener;
3 import android.location.LocationManager;

Create a LocationManager and LocationListner objects in our main “GoogleMapsActivity” Class.

1 LocationManager locMgr;
2 MyLocationListener locLstnr;

Now Create a whole new class by the name of MyLocationListner inside the GoogleMapsActivity class.

1 public class MyLocationListener implements LocationListener


2 {
3 @Override
4 public void onLocationChanged(Location loc)
5 {
6 loc.getLatitude();
7 loc.getLongitude();
8 String Text = "My current location is: " +
9 "Latitud = " + loc.getLatitude() +
10 "Longitud = " + loc.getLongitude();
11 Toast.makeText( getApplicationContext(), Text, Toast.LENGTH_SHORT).show();
12
13 }
14

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl... Página 3 de 17

15 @Override
16 public void onProviderDisabled(String provider)
17 {
18 Toast.makeText( getApplicationContext(),
19 "Gps Disabled",
20 Toast.LENGTH_SHORT ).show();
21 }
22
23 @Override
24 public void onProviderEnabled(String provider)
25 {
26 Toast.makeText( getApplicationContext(),
27 "Gps Enabled",
28 Toast.LENGTH_SHORT).show();
29 }
30
31 @Override
32 public void onStatusChanged(String provider, int status, Bundle extras)
33 {
34
35 }
36
37 }

Now in the GoogleMapsActivity class add the following lines of code to create the LocationManager object and
MyLocationListner object.

1 locMgr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
2 locLstnr = new MyLocationListener();
3 locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locLstnr);

Check the picture below. In the image below will have used DDMS to send dummy coordinates to our
emulator. We have to keep a few points in mind when sending dummy coordinates to emulator.

Toast displaying our dummy coordinates sent from DDMS to our emulator.

First of all emulator should be select in the Devices Tab in the DDMS. In the above picture my device is shown
as emulator-5554. Secondly while the device selected. Open the Emulator Control Tab, Inside that tab open the
Manual Tab and scroll down to location controls. Now click send and you will see a toast appear on our
emulator displaying our message including coordinates that we have just sent from DDMS. With this step our
first phase of the tutorial is complete. To animate the GoogleMap to the location of the Coordinates that we
have received. Add the following code in the onLocationChanged method of our MyLocationListner Class

1 String coordinates[] = {""+loc.getLatitude(), ""+loc.getLongitude()};


2 double lat = Double.parseDouble(coordinates[0]);
3 double lng = Double.parseDouble(coordinates[1]);

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl... Página 4 de 17

4
5 GeoPoint p = new GeoPoint(
6 (int) (lat * 1E6),
7 (int) (lng * 1E6));
8
9 mc.animateTo(p);
10 mc.setZoom(7);
11 mapView.invalidate();

Comment the code that displays the Toast and run the Project. Send dummy locations from DDMS and we will
see that the Map will animate to the location of the coordinates that we have provided from DDMS.

Note:- Please leave your comments if this article was helpful.

Next tutorial on its way ( adding images to GoogleMaps, OverLays )

Related articles

Android Google Maps Tutorial Part 7, Drawing A Path or Line Between Two Locations
(mirnauman.wordpress.com)
Android Google Maps Tutorial Part 1. Basic Development. (mirnauman.wordpress.com)
Android Google Maps Tutorial Part 6, Getting The Location That Is Touched. (mirnauman.wordpress.com)
Android Google Maps Tutorial Part 3. Adding An Image to GoogleMaps Using Map Overlays.
(mirnauman.wordpress.com)
Android Google Maps Tutorial Part 5, Adding Multiple Images To Google Maps Using ItemizedOverlay.
(mirnauman.wordpress.com)
About these ads

Share this:

Like this:

Be the first to like this.

58 comments
Comments feed for this article

February 13, 2012 at 6:18 am [...] http://mirnauman.wordpress.com/2012/02/07/using-


Adding image to GoogleMaps using gps-in-android-and-animating-google-maps-to-the-curr…
map overlays. Android tutorial Part [...]
3 « Mir Reply

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl... Página 5 de 17

February 14, 2012 at 9:45 am [...] http://mirnauman.wordpress.com/2012/02/07/using-


Android Google Maps Tutorial Part gps-in-android-and-animating-google-maps-to-the-curr…
4, Adding Menu & Some Additional [...]
Functionality Like Zooming, Reply
Changing Map View, Animating To
GPS Current Location Using Menu
Button. « Mir

March 10, 2012 at 7:22 am Hi,


martin
I’m new to android development. I got part 1
working but can’t get this one to work. Could you please also post the full
code of GoogleMapsActivity for part 2?

Thanks

Regards,
Martin

Reply

March 12, 2012 at 3:13 pm okey i ll soon post the complete code,
Mir but now that code is evolved to part 5, i
have not even posted tutorial for part 5. so
have no worries. i ll post the the complete code with part 5 soon. u can get the
part that is only related to GPS from that code.

Reply

March 26, 2012 at 6:00 pm The method getApplicationContext() is


mrajab undefined for the type
MyLocationListener

Reply

March 27, 2012 at 4:52 am dear mrajab,


Mir can u debug and tell me where exactly
the error is generated. Am not sure about the
error that u r getting, why and where, but u can try one of the following.
GoogleMapsActivity.getApplicationContext or
Context or this
Do write details of ur error and if any of the above helps do write which one
solved ur error.

Reply

March 27, 2012 at 5:48 pm Greet i update my code to context.


mrajab Thanks & regards

Reply

March 31, 2012 at 8:58 pm Thank u very much . you are a great
soso helpfull programmer
but this code : locMgr = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
locLstnr = new MyLocationListener();

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl... Página 6 de 17

locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locLstnr);

still made me errors


i will fix it inshallah
God bless youuu.

Reply

April 2, 2012 at 4:32 am Thanks for appreciating my efforts.


Mir
Reply

April 7, 2012 at 4:22 pm hello,,,can u help me in coding of add a


soso menu(with its options ) to our project

and how to embed a text view to it (like option that open a text or pictures ) ?!

thanks for ur help

Reply

April 10, 2012 at 12:15 pm [...] http://mirnauman.wordpress.com/2012/02/07/using-


Android Google Maps Tutorial Part gps-in-android-and-animating-google-maps-to-the-curr…
5, Adding Multiple Images To [...]
Google Maps Using Reply
ItemizedOverlay. « Mir

April 16, 2012 at 9:25 am [...] Android Google Maps Tutorial Part 2. Using GPS in
Android Google Maps Tutorial Part Android and Animating Google Maps to the Current G…
6, Getting The Location That Is (mirnauman.wordpress.com) [...]
Touched. « Mir Reply

April 30, 2012 at 1:46 pm Please reply to this post:


Android Development
http://learnglobally.wordpress.com/2012/04/30/problem-using-android-
mapactivity/

Reply

May 2, 2012 at 4:15 am u have not posted ur xml file code. plz
Mir post that so that i can have a clear idea
of the application, 2ndly i wanted to know that
do u have only 1 activity in this application or ur have two activities. one wild
guess wud be, check the xml file, do u have a mapview control in it. also
check the manifest, do u have com.google.android.maps library added or not.
the rest we can see when u post ur xml code as well.

Reply

May 2, 2012 at 3:40 pm ok I have solved tht problem…


Android Development please post some material about the web
services.
How to store user’s current location on a web server.
i am using Php, Mysql, for this purpose.

May 6, 2012 at 6:30 pm


Android Development

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl... Página 7 de 17

please reply to the following link.


http://learnglobally.wordpress.com/2012/05/06/showing-circle-on-current-
location-in-android/

May 6, 2012 at 6:45 pm Please Reply to the following link:


Android Development
http://learnglobally.wordpress.com/2012/05/06/showing-circle-on-current-
location-in-android/

May 14, 2012 at 5:36 am In fact i am developing an android


Shakeel (android Developer) application now a days.
I want to track a person having an android
phone and running my application.
What my application will do?
>> Tell user his/her Current Location; with the result it will return the
Latitude and Longitude values, i have saved these values in variables,
I want to send these points on a web server using PHP coding.
Please tell me if you can help me in this regard.

May 18, 2012 at 6:35 am Hi Dear:


Shakeel (android Developer) i want to develop an Android
application showing 5 markers/points in
google maps. Is there anybody who already has done this task and know
about how it will be accomplished.
Please reply as soon as possible if any body know. Thanks.

May 9, 2012 at 3:54 am Reblogged this on Mir.


Mir
Reply

June 1, 2012 at 9:00 am goood one!!!!!!!!!!!!!!!!!!!!!!!!


sabu
Reply

June 27, 2012 at 10:30 am Great Tutorial! So far it has fascinated


Asif Tasleem me a lot.

Reply

September 10, 2012 at 8:02 am Very nice tutorial sir i like so much.It’s
kuldeep so easy in understanding.But i need to
show path between two cities trough
walk,bus,train,car.Can you help me?
Thanks in advance

Reply

September 10, 2012 at 8:32 amso far google dont provide anything in
Mir the android sdk that can automate
drawing paths on roads etc. but u can use
Open Street Map Api to achieve that objective. so far i have not used it
myself. but planning to.

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl... Página 8 de 17

Reply

September 12, 2012 at 10:36 am I am into the android development as a


anand kumar newbie and a colleague of mine gave me
your link. I am working on integration google
map for an app and this is my bible!

Reply

September 18, 2012 at 9:36 am Hi Mir. First of all I trouly admire your
Dave work. It helps me learning the basics of
developing to android and google API’s.
As you understand Im new at the Android apps development and I worked
according to your explanations but I couldn’t make this part works.
I added my code below. maybe youll find whats wrong.
The problem is with the initialization of LocationManager and
MyLocationListener. It dosn’t compile.
What have I done wrong?
Thanks
Dave
——

package com.test.mylocation;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class MyLocation extends MapActivity


{

private MapView mapView;


private MapController mc;

LocationManager locMgr;
MyLocationListener locLstnr;

locMgr = (LocationManager)getSystemService
(Context.LOCATION_SERVICE);
locLstnr = new MyLocationListener();
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locLstnr);

/** Called when the activity is first created. */


@Override
public void onCreate(Bundle savedInstanceState)
{

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Googl... Página 9 de 17

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_im_here);

mapView = (MapView) findViewById(R.id.mapview1);


mc = mapView.getController();

String coordinates[] = {“30″, “71″};


double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);

GeoPoint p = new GeoPoint(


(int) (lat * 1E6),
(int) (lng * 1E6));

mc.animateTo(p);
mc.setZoom(7);
mapView.invalidate();
}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}

public class MyLocationListener implements LocationListener


{
@Override
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
String Text = “My current location is: ” +
“Latitud = ” + loc.getLatitude() +
“Longitud = ” + loc.getLongitude();
Toast.makeText( getApplicationContext(), Text,
Toast.LENGTH_SHORT).show();

@Override
public void onProviderDisabled(String provider)
{
Toast.makeText( getApplicationContext(),
“Gps Disabled”,
Toast.LENGTH_SHORT ).show();
}

@Override
public void onProviderEnabled(String provider)
{
Toast.makeText( getApplicationContext(),
“Gps Enabled”,
Toast.LENGTH_SHORT).show();
}

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Go... Página 10 de 17

@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{

Reply

November 3, 2012 at 5:47 pm i have analyze your code as for my


panchanan knowledge on GPS system it is correct.it
is run correct 2.3.1.if your code is not running
the you check your manifest.xml for uses permission for
android.permission.INTERNET
android.permission.ACCESS_FINE_LOCATION,and
ACCESS_COARSE_LOCATION.please check it.

Reply

September 20, 2012 at 6:53 pm am using am emulator and i dont think it


ndesti has real GPS funtionalities because it
cant track my current location

Reply

September 21, 2012 at 8:27 am u have to create the AVD with GPS.
Mir than ur code will only work when u send
fake coordinates from ur DDMS. it will not
work by itself. u have to write the fake coordinates in the DDMS GPS section
and than click the button to send those coordinates to the emulator. than ur
map will show u those coodinates and will consider them as ur current
location

Reply

September 25, 2012 at 2:29 pm package com.example.testmap;


Muiz
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;

import android.os.Bundle;
import android.widget.Toast;

public class Gmap extends MapActivity {


LocationManager locMgr;
MyLocationListener locLstnr;

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Go... Página 11 de 17

private MapView mapView;


private MapController mc;
Location loc;

/** Called when the activity is first created. */


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mapView = (MapView) findViewById(R.id.mapview);


mc = mapView.getController();

String coordinates[] = {“”+loc.getLatitude(), “”+loc.getLongitude()};

double lat = Double.parseDouble(coordinates[0]);


double lng = Double.parseDouble(coordinates[1]);

GeoPoint p = new GeoPoint(


(int) (lat * 1E6),
(int) (lng * 1E6));

mc.animateTo(p);
mc.setZoom(7);
mapView.invalidate();

locMgr = (LocationManager)getSystemService
(Context.LOCATION_SERVICE);
locLstnr = new MyLocationListener();
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locLstnr);

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
public class MyLocationListener implements LocationListener
{

@Override
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
String Text = “My current location is: ” +
“Latitud = ” + loc.getLatitude() +
“Longitud = ” + loc.getLongitude();
Toast.makeText( getApplicationContext(), Text,
Toast.LENGTH_SHORT).show();

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Go... Página 12 de 17

@Override
public void onProviderDisabled(String provider)
{
//Toast.makeText( getApplicationContext(),
// “Gps Disabled”,
//Toast.LENGTH_SHORT ).show();
}

@Override
public void onProviderEnabled(String provider)
{
//Toast.makeText( getApplicationContext(),
// “Gps Enabled”,
//Toast.LENGTH_SHORT).show();
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{

}
}

unfortunately testmap has been stopped. what did i do wrong here? reply me
ASAP pls

Reply

September 26, 2012 at 3:47 am Dear Muiz,


Mir plz print the error. that might me helpful
to figure out wats wrong or wat needs to be
tweeked.

Reply

September 26, 2012 at 4:00 am i managed to fix it but when i run it the
Muiz map doesnt show up

September 26, 2012 at 4:10 am wat u see, an empty map grid or a black
Mir screen.

September 26, 2012 at 7:59 am a grid view


Muiz

September 26, 2012 at 11:38 am check ur google maps api key


Mir

February 6, 2013 at 6:55 am I tried ur 1st and 2nd tutorials, 1st runs
tayyabajan successfuly but 2nd one displays on
emulator “unfortunately googlemaps
stopped”. it just show black screen.

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Go... Página 13 de 17

September 29, 2012 at 3:37 pm i need some help


umar i am making a projrect in which i
received the GPS coordinates througth sms
into the google andriod phone .
my problem is i want to put the the coordinates from inbox of the andriod
phone in to the google map through some application.
Means the app should continuously get the coordinates from inbox and insert
the coordinates for real time tracking plzzzzzz plzzzzzzzzzz plzzzzzzzzzzz
any one help me out

Email: omar3228422552@gmail.com

Reply

October 1, 2012 at 1:59 pm sorry!


pungkreatif (@pungkreatif)
The application
WDGoogleMaps (process com.
melajah.wdgooglemaps)has
stopped unexpectedly. Please
try again.

Force close

Hi,Master Mr. Mir


I’m newbie please help me master. what should i do..?

Reply

October 2, 2012 at 4:57 am plz try to print the error, in log, etc, so
Mir that we can have a clear idea wat
actually causes the application to crash

Reply

October 2, 2012 at 10:26 amthere is no error,, when i runing this


pungkreatif (@pungkreatif) aplication the message come up is force
close

October 4, 2012 at 12:08 pm This is Log Error :


pungkreatif (@pungkreatif) Thank a lots before master.
10-04 12:05:24.285: E/AndroidRuntime(372):
FATAL EXCEPTION: main
10-04 12:05:24.285: E/AndroidRuntime(372): java.lang.RuntimeException:
Unable to start activity ComponentInfo
{com.melajah.wdgooglemaps/com.melajah.wdgooglemaps.GooglemapsActivity}:
java.lang.NullPointerException
10-04 12:05:24.285: E/AndroidRuntime(372): at
android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:1647)
10-04 12:05:24.285: E/AndroidRuntime(372): at
android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:1663)
10-04 12:05:24.285: E/AndroidRuntime(372): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Go... Página 14 de 17

10-04 12:05:24.285: E/AndroidRuntime(372): at


android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-04 12:05:24.285: E/AndroidRuntime(372): at
android.os.Handler.dispatchMessage(Handler.java:99)
10-04 12:05:24.285: E/AndroidRuntime(372): at android.os.Looper.loop
(Looper.java:130)
10-04 12:05:24.285: E/AndroidRuntime(372): at
android.app.ActivityThread.main(ActivityThread.java:3683)
10-04 12:05:24.285: E/AndroidRuntime(372): at
java.lang.reflect.Method.invokeNative(Native Method)
10-04 12:05:24.285: E/AndroidRuntime(372): at
java.lang.reflect.Method.invoke(Method.java:507)
10-04 12:05:24.285: E/AndroidRuntime(372): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:839)
10-04 12:05:24.285: E/AndroidRuntime(372): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-04 12:05:24.285: E/AndroidRuntime(372): at
dalvik.system.NativeStart.main(Native Method)
10-04 12:05:24.285: E/AndroidRuntime(372): Caused by:
java.lang.NullPointerException
10-04 12:05:24.285: E/AndroidRuntime(372): at
com.melajah.wdgooglemaps.GooglemapsActivity.onCreate
(GooglemapsActivity.java:33)
10-04 12:05:24.285: E/AndroidRuntime(372): at
android.app.Instrumentation.callActivityOnCreate
(Instrumentation.java:1047)
10-04 12:05:24.285: E/AndroidRuntime(372): at
android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:1611)
10-04 12:05:24.285: E/AndroidRuntime(372): … 11 more

October 2, 2012 at 10:53 am i send the LongCat :


pungkreatif (@pungkreatif) tag : android runtime
text : FATAL EXCEPTION: main
text : java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.melajah.wdgooglemaps/com.melajah.wdgooglemaps.GooglemapsActivity}:
java.lang.NullPointerException
text : at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:1647)

……
…..
….
….
…..
….
11 more

Reply

October 12, 2012 at 9:30 am

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Go... Página 15 de 17

kumar dear Mir, i am a newbie to android and


gps. I have tried what u told in the tutorial. I
am getting an error :

“the type maps must implement the inherited abstract method


LocationListener.onLocationChanged(location),”
The same is for onProviderDisabled and the other two that are written in
MyLocationListener class.

where ”maps” is my main maps class.

will you please tell me , why am i getting this. a quick response would me
much helpful sir.

Reply

October 12, 2012 at 5:50 pm Hello,


JTA Can anyone tell me how can i use the
GPS requestLocationUpdates and insert that
values in a postgreSql? Here can i find information about that?
Many thanks.

Reply

October 16, 2012 at 11:04 am hello, i followed what you have told but
speed ended up with a empty grid on top of it
longitude and latitude are displayed . To get
the map below it, what should i do, can you please tell me where the error
could be ? thanks in advnce.

Reply

October 16, 2012 at 11:22 am Check your google maps Api key.
Mir
https://mirnauman.wordpress.com/2012/01/26/how-to-get-google-maps-api-
key-for-android-issues-and-errors-solved/

Reply

November 28, 2012 at 10:45 am Hello Mir,


Yusuf Great Map and GPS Android project.
But when i run the project after implementing
GPS my application stops in the emulator and logcat displays the following
message:

Package com.example.googlemapsactivity requires unavailable shared library


com.google.android.maps; failing!

But if i run only the map project without implementing GPS, it is running
well. I have checked that i am using Google API 10 2.3.3

Please help.

Reply

November 28, 2012 at 11:55 am


Mir

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Go... Página 16 de 17

from implementing GPS you mean wat, which block of code are u referring
to that is crashing the app.

Reply

December 14, 2012 at 9:33 am Good day. Try your case on a real
Sergey device Samsung Galaxy Gio – Android
2.3.6, and so the map is displayed on it, and
does not show my location. The code is correct, as all of you. Help solve the
problem?

Reply

December 14, 2012 at 11:43 am please tell me wat happens when u click
Mir the my current location button

Reply

December 14, 2012 at 6:40 pm I’m sorry, I tried in the building. In open
Sergey areas all works fine. Thank you.

January 2, 2013 at 11:50 am very nice and useful article ,,


Mahmoud Hosny
Reply

February 5, 2013 at 1:04 pm Very Nice Tuto


Cheikh Ahmadou Bamba
Diop Reply

February 6, 2013 at 6:58 am plz help me…. it z so urjent


tayyabajan
Reply

March 3, 2013 at 5:30 pm [...] Android Google Maps Tutorial Part 2. Using GPS in
Drawing A Path or Line Between Android and Animating Google Maps to the Current
Two Locations (Google Maps in G… (mirnauman.wordpress.com) [...]
Android) » Muhammad Yusro Reply

March 13, 2013 at 4:40 am thank you for your creat tutorial. but i
help me have a problem. it is working and appear
map in device. but is not show location . can
please put full source to download . anyone can this please send me project.
please tnx

Reply

March 30, 2013 at 7:46 am Hello sir,


Dhanvarshini Missing styles. Is the correct theme
chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or
fix the theme style references.Failed to find style ‘mapViewStyle’ in current
theme
I am getting the above error while creating mapview in xml can give me a
solution

Reply

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013
Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Go... Página 17 de 17

April 9, 2013 at 5:49 pm Sir! ur tutorials help me a lot.. i m


Sanya planning to make a restaurant finder app
in android, can u plz help me for that??

Reply

L E A V E A R E P LY

http://mirnauman.wordpress.com/2012/02/07/using-gps-in-android-and-animating-go... 08/10/2013

Вам также может понравиться