Showing current location in Google Maps using API V2 with SupportMapFragment

January 6, 2013
By

In this article, we will create an Android application which will display current location in Google Maps using Google Maps Android API V2.



Since the Google Map is displayed using SupportMapFragment, this application can run in Android API Level 8 or above.

In order to use MapFragment for Google Maps, we need Android device with API level 12 or above.



This application is developed in Eclipse 4.2.1 with ADT plugin ( 21.0.0 ) and Android SDK ( 21.0.0 ). This application is tested in a real Android Phone with Android ( 2.3.6 ).

An alternative method for this application is available at Showing current location using OnMyLocationChangeListener in Google Map Android API V2


1. Download and configure Google Play Services Library in Eclipse

Google Map for Android is now integrated with Google Play Services. So we need to set up Google Play Service Library for developing Google Map application in Android.

Please follow the given below link to setup Google Play Service library in Eclipse.

http://developer.android.com/google/play-services/setup.html


2. Create a new Android Application Project namely “LocationInGoogleMapV2″

Create a new Android Application Project

Figure 1 : Create a new Android Application Project


3. Configure Android Application Project

Configure Project

Figure 2 : Configure Project


4. Design Application Launcher Icon

Designing Application Launcher Icon

Figure 3 : Designing Application Launcher Icon


5. Create a blank activity

Create a blank activity

Figure 4 : Create a blank activity


6. Enter Main Activity Details

Enter Main Activity Details

Figure 5 : Enter Main Activity Details


7. Link to Google Play Service Library

Link Google Play Services Library to this project

Figure 6 : Link Google Play Services Library to this project


8. Get the API key for Google Maps Android API v2 

We need to get an API key from Google to use Google Maps in Android application. Please follow the given below link to get the API key for Google Maps Android API v2.

https://developers.google.com/maps/documentation/android/start


9. Add Android Support library to this project

By default, Android support library (android-support-v4.jar ) is added to this project by Eclipse IDE to the directory libs. If it is not added, we can do it manually by doing the following steps :

  • Open Project Explorer by Clicking “Window -> Show View -> Project Explorer”
  • Right click this project
  • Then from popup window, Click “Android Tools -> Add Support Library “

10. Update the file res/values/strings.xml


<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">CurrentLocation</string>
    <string name="hello_world">Hello world!</string>
    <string name="menu_settings">Settings</string>
</resources>


11. Update the file AndroidManfiest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="in.wptrafficanalyzer.locationingooglemapv2"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <permission
        android:name="in.wptrafficanalyzer.locationingooglemapv2.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>

    <uses-permission android:name="in.wptrafficanalyzer.locationingooglemapv2.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="in.wptrafficanalyzer.locationingooglemapv2.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
             android:value="YOUR_API_KEY"/>

    </application>
</manifest>

Note : In the above code, replace “YOUR_API_KEY” with the api key, you generated in step 8.


12. Update the layout file to display Google Map using SupportMapFragment


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/tv_location"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/tv_location"
        class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>


13. Update the file src/in/wptrafficanalyzer/locationingooglemapv2/MainActivity.java


package in.wptrafficanalyzer.locationingooglemapv2;

import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.TextView;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;

public class MainActivity extends FragmentActivity implements LocationListener {

    GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // Getting Google Play availability status
        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

        // Showing status
        if(status!=ConnectionResult.SUCCESS){ // Google Play Services are not available

            int requestCode = 10;
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
            dialog.show();

        }else { // Google Play Services are available

            // Getting reference to the SupportMapFragment of activity_main.xml
            SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

            // Getting GoogleMap object from the fragment
            googleMap = fm.getMap();

            // Enabling MyLocation Layer of Google Map
            googleMap.setMyLocationEnabled(true);

            // Getting LocationManager object from System Service LOCATION_SERVICE
            LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

            // Creating a criteria object to retrieve provider
            Criteria criteria = new Criteria();

            // Getting the name of the best provider
            String provider = locationManager.getBestProvider(criteria, true);

            // Getting Current Location
            Location location = locationManager.getLastKnownLocation(provider);

            if(location!=null){
                onLocationChanged(location);
            }
            locationManager.requestLocationUpdates(provider, 20000, 0, this);
        }
    }
    @Override
    public void onLocationChanged(Location location) {

        TextView tvLocation = (TextView) findViewById(R.id.tv_location);

        // Getting latitude of the current location
        double latitude = location.getLatitude();

        // Getting longitude of the current location
        double longitude = location.getLongitude();

        // Creating a LatLng object for the current location
        LatLng latLng = new LatLng(latitude, longitude);

        // Showing the current location in Google Map
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

        // Zoom in the Google Map
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));

        // Setting latitude and longitude in the TextView tv_location
        tvLocation.setText("Latitude:" +  latitude  + ", Longitude:"+ longitude );

    }

    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}


14. Enable GPS in the device from Settings


15. Running the application

Showing current location in Google Map Android API V2

Figure 7 : Showing current location in Google Map Android API V2


16. Download Source Code


17. Tryout

We can tryout this application from Google Play Store at https://play.google.com/store/apps/details?id=in.wptrafficanalyzer.locationingooglemapv2

 


How to hire me?

I am George Mathew, working as software architect and Android app developer at wptrafficanalyzer.in

You can hire me on hourly basis or on project basis for Android applications development.

For hiring me, please mail your requirements to info@wptrafficanalyzer.in.

My other blogs
store4js.blogspot.com


Android Knowledge Quiz

Ready to test your knowledge in Android? Take this quiz :



Tags: , , , , , , ,

74 Responses to Showing current location in Google Maps using API V2 with SupportMapFragment

  1. Techi on January 11, 2013 at 1:57 pm

    Hi George, Sorry but again in trouble. Getting nullpointerException on line googleMap.setMyLocationEnabled(true); any ideas what might be the problem.
    Thanks in advance.

    • george on January 11, 2013 at 6:10 pm

      Hi,
      I am not able to reproduce any NullPointerException as you mentioned. May be you missed some steps at somewhere.

    • Amit Bhaliya on November 12, 2013 at 7:41 pm

      Hello Sir,
      I can not able add google play service lib as reference library so please help me

      • Jingyun Zhang on December 29, 2013 at 7:52 pm

        hi, I used to get the same problem.

        click copy into my workplace when you referencing google_play_service.lib

        hope it could solve your problems

  2. raneem Alharthi on January 18, 2013 at 5:42 am

    Hi’
    is ti also working for indoor localization?

  3. anto on January 18, 2013 at 10:45 pm

    Hi and thanks for the tutorial.

    How can I add a possibility for the user to activate the GPS localization ?

    Thanks

    • Loki on June 2, 2013 at 10:39 pm

      Have you figured out how to provide option to activate GPS from application and then returning back to the application with the current location on maps.

  4. Ranjith Kumar on January 24, 2013 at 5:24 pm

    For me only white screen shown no map :(

    • george on January 24, 2013 at 9:21 pm

      Are you getting any hint from logcat messages?

  5. Michael on February 3, 2013 at 1:19 am

    Dear George,

    Nice tutorial.

    I too am getting only a white/grey screen with no map. but i do get my longitude and langitude.

    Do u have any idea what is causing this problem?
    I have tried many other solutions/examples and nvr get the map to show on my device. (I have a 2.2 Froyo device)

    When i try it on a AVD emulator i am getting a
    FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{
    com.example.test3/com.example.test3.MainActivity}: java.lang.NullPointerException

    • george on February 3, 2013 at 6:40 am

      Dear Michael,
      Please ensure that, the correct API key is entered in the AndroidManifest.xml.

      Google Maps Android API V2 applications will not be executed in emulators since it require Google Play Services library.

      • alaintchato on March 21, 2013 at 4:15 pm

        I too i’m getting on the white screen with lat and long.
        I assure you that my API KEY and package name are correct
        What could be the problem

        • alaintchato on March 21, 2013 at 4:21 pm

          Also, my logcat doesn’t show anything significant..only some ‘pause 4ms+…’ stuff

  6. mellon on February 7, 2013 at 8:44 am

    thanks, it’s very helpful. Finally found the solution to show current location!!!!

  7. ign on March 7, 2013 at 12:24 am

    Thanks man, worked like a charm!

    As for those who have white screen problems – make sure that you got the right API key and package name is yours one (if you’ve changed it while following the tutorial) in AndroidManifest.xml

  8. amit on March 12, 2013 at 7:13 pm

    very nice solution.but provide me configartion for Mapv2 for android

  9. Muhammad Salahuddin on March 29, 2013 at 6:17 pm

    Hi..AOA
    I am working on google maps in android app . I want reverse geocoding but it doesnt works and give warning ” Service not available” . please help me……………..

  10. Steven on April 11, 2013 at 9:13 am

    Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
    hepl me!

    • taha on May 15, 2013 at 12:28 pm

      hi , r u using SupportMapFragment

      • Huseyin Igde on November 27, 2013 at 3:38 am

        I have an error. Error is :
        Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class fragment

        XML File :
        Line 12 :

        Java Class :
        SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

        // Getting GoogleMap object from the fragment
        googleMap = fm.getMap();

        // Enabling MyLocation Layer of Google Map
        googleMap.setMyLocationEnabled(true);

        • kishore on May 27, 2014 at 3:09 pm

          please help me i downloaded the Source code and Obtain a Google Maps API key. and Add Google Play Services
          but iam get “the application MyLocation(process in.Wptrafficanalyzer,locationingooglemapv2)has stooped unexpectedly.please try agin”

  11. Dave on April 14, 2013 at 1:38 am

    Thank You George, concise and in depth tutorials, easy to follow even for beginners like me. Bookmarked as a great Android resource

  12. Athul on April 18, 2013 at 12:34 pm

    hai brother i downloaded your app and run it in ma Tab with my API key but the logcat shows Failed to load MAP could not contact google servers what should i have to do the screen is showing the longitude and lanti of my current location
    thank you

    • Athul on April 18, 2013 at 12:37 pm

      thank you brother i have solved it great job for you thank you very much

  13. Athul on April 18, 2013 at 2:05 pm

    04-18 14:02:57.110: E/AndroidRuntime(14414): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at android.app.ActivityThread.access$600(ActivityThread.java:123)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at android.os.Handler.dispatchMessage(Handler.java:99)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at android.os.Looper.loop(Looper.java:137)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at android.app.ActivityThread.main(ActivityThread.java:4424)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at java.lang.reflect.Method.invokeNative(Native Method)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at java.lang.reflect.Method.invoke(Method.java:511)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
    04-18 14:02:57.110: E/AndroidRuntime(14414): at dalvik.system.NativeStart.main(Native Method)

  14. Ram kiran on April 24, 2013 at 5:06 pm

    Really Nice Explanation. I tried a lot and search many sites. But find solution here only. Thanks for the post.

  15. newbie on April 25, 2013 at 10:30 am

    Hi, George! Thanks for this great tutorial, really helped me.
    I’ve got problem with GooglePlayServicesUtil. Its says “cannot be resolved”. How to fix it??

    sorry for my bad english :p

    • george on April 25, 2013 at 10:50 am

      Ensure that, you downloaded and configured Google Play Services library as mentioned in the Step 1.

      Once Google Play Services library is configured, then link that library to this project as shown in the Step 7.

      • newbie on April 25, 2013 at 11:24 am

        i did

      • newbie on April 25, 2013 at 11:30 am

        sorry its my mistake, I forgot to add the import things. Thanks George

  16. Priyank Pandya on April 26, 2013 at 6:43 pm

    i got the lantitute and latitude bt not getting map in place of that getting white screen

    • george on April 26, 2013 at 8:20 pm

      In this application the latitude and longitude are obtained using LocationManager api.

      If you are getting a white screen instead of map, probably you may not have entered the correct Android API Key in AndroidManifest.xml file.

      • Priyank Pandya on April 29, 2013 at 9:46 am

        I put the appropriate Api key also bt i think is there any other apk we need to install before run this application…??

        • george on April 29, 2013 at 11:02 am

          Please check the logcat to get a hint on the white screen

          • Priyank Pandya on April 29, 2013 at 2:03 pm

            logcat is not showing any error..

          • Priyank Pandya on May 6, 2013 at 10:03 am

            hy george i still face the proble,
            i got the zoom in and zoom out button bt don’t get any map..

            Thanx in Advance

          • george on May 6, 2013 at 10:15 am

            Hi Priyank Pandya,
            Please ensure that, Google Maps Android API v2 service is enabled in Google APIs Console.

  17. hosni on April 29, 2013 at 12:33 am

    this app won’t run unless you update google play services

  18. Rasmus Friis on May 5, 2013 at 9:33 pm

    Hi George,

    We are making a running app for school, and i have tried several different ways of showing the current users MyLocation, your solution works great.

    But when you are moving, the camera does not update your current new location, so it is in the middle of the screen the whole time. Why is that, i cant find a solution for google Maps v2 which will move to the rigt location automatic. Hope you can help me.

    • george on May 6, 2013 at 9:50 am

      Hello Rasmus,

      This application will automatically update the current location, even when the device is moving.

  19. deepika on May 8, 2013 at 10:48 pm

    hi
    i m making an alarm based application in android and for this i need to get current train locations , how can i get these type of details plzz help me asap. thanks

  20. Zero on May 9, 2013 at 9:49 am

    I had problem in logcat “can’t redirect to app setting for Google Play Services”??

  21. razi on May 10, 2013 at 8:42 pm

    why i didn’t got bid blue circle?

  22. bhupal on May 22, 2013 at 4:56 pm

    i am getting an error in

    the error is Unexpected namespace prefix “xmlns” found for tag fragment

  23. bhupal on May 22, 2013 at 5:05 pm

    I’m getting on the white screen with lat and long..how can it resolve this

  24. budaq on May 23, 2013 at 2:11 am

    helo george ..
    i want ask something..why my emulator take time tO launched..

  25. Priyank Pandya on May 23, 2013 at 12:25 pm

    hi George
    Do u know how make “Add connection” in android contacts..
    as i want to add contact using my account

    Thnx…

  26. Basribaz on May 25, 2013 at 5:27 am

    05-25 07:46:50.922: E/dalvikvm(5727): Could not find class ‘com.google.android.gms.maps.model.LatLng’, referenced from method com.bas.wisatasulawesi.Posisi.onLocationChanged

    help please, thanks

  27. Raza Asif on May 28, 2013 at 12:50 pm

    Hi George,

    Everything is according to your tutorial and I am also getting the current location but the map is not displaying. My API key is correct and Google Maps Android API v2 service is also running, still I don’t get it what’s going wrong please advise.

  28. JK on May 29, 2013 at 8:42 am

    Thank you very much. You helped me.

  29. hasnae on June 4, 2013 at 3:50 pm

    what can i add to this cod to show this position with (latitude and logntitude)

  30. bacbim on June 19, 2013 at 7:14 pm

    Hello,I’m having a problem.My logcat show as below.Please help me!
    06-19 20:41:05.169: E/AndroidRuntime(32447): FATAL EXCEPTION: main
    06-19 20:41:05.169: E/AndroidRuntime(32447): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{in.wptrafficanalyzer.locationingooglemapv2/in.wptrafficanalyzer.locationingooglemapv2.MainActivity}: java.lang.ClassNotFoundException: in.wptrafficanalyzer.locationingooglemapv2.MainActivity in loader dalvik.system.PathClassLoader[/data/app/in.wptrafficanalyzer.locationingooglemapv2-1.apk]
    06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at android.os.Handler.dispatchMessage(Handler.java:99)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at android.os.Looper.loop(Looper.java:130)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread.main(ActivityThread.java:3683)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at java.lang.reflect.Method.invokeNative(Native Method)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at java.lang.reflect.Method.invoke(Method.java:507)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
    06-19 20:41:05.169: E/AndroidRuntime(32447): at dalvik.system.NativeStart.main(Native Method)
    06-19 20:41:05.169: E/AndroidRuntime(32447): Caused by: java.lang.ClassNotFoundException: in.wptrafficanalyzer.locationingooglemapv2.MainActivity in loader dalvik.system.PathClassLoader[/data/app/in.wptrafficanalyzer.locationingooglemapv2-1.apk]
    06-19 20:41:05.169: E/AndroidRuntime(32447): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)

    • Alex on June 26, 2013 at 1:07 am

      Me too

  31. Rowan Krishnan on July 3, 2013 at 10:15 am

    Amazing tutorial, thanks so much for making this. Worked perfectly.

  32. Monika on July 3, 2013 at 5:44 pm

    Its working but i cant zoom into my location, it zooms near it, how can i solve it ? any ideas?

  33. Joe jackol on July 26, 2013 at 5:00 pm

    this is cool man,thanks a lot dude,this is the best google maps tutorial i ever found in google

  34. Julio Cesar Vivas on August 6, 2013 at 3:35 am

    Muchas por este ejemplo. Esta increíble.

    Saludos.

  35. Himanshu on August 11, 2013 at 7:15 pm

    In the Logcat , I am gettinng such error
    No class found for Main Activity
    I have downloaded ur project!1

    • George Mathew on August 11, 2013 at 7:20 pm

      Hi,
      Please do the following :

      * Open properties window by right clicking the project from eclipse’s package explorer

      * Select Java Build Path -> Order and Export tab

      * Ensure “Android Private Libraries” is checked

      * If unchecked, “check” it and click ok

      * Clean and Build the project and run the application

      • Himanshu on August 11, 2013 at 7:32 pm

        Sir still no luck

        I am also getting this

        06-19 20:41:05.169: E/AndroidRuntime(32447): FATAL EXCEPTION: main
        06-19 20:41:05.169: E/AndroidRuntime(32447): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{in.wptrafficanalyzer.locationingooglemapv2/in.wptrafficanalyzer.locationingooglemapv2.MainActivity}: java.lang.ClassNotFoundException: in.wptrafficanalyzer.locationingooglemapv2.MainActivity in loader dalvik.system.PathClassLoader[/data/app/in.wptrafficanalyzer.locationingooglemapv2-1.apk]
        06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at android.os.Handler.dispatchMessage(Handler.java:99)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at android.os.Looper.loop(Looper.java:130)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at android.app.ActivityThread.main(ActivityThread.java:3683)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at java.lang.reflect.Method.invokeNative(Native Method)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at java.lang.reflect.Method.invoke(Method.java:507)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
        06-19 20:41:05.169: E/AndroidRuntime(32447): at dalvik.system.NativeStart.main(Native Method)
        06-19 20:41:05.169: E/AndroidRuntime(32447): Caused by: java.lang.ClassNotFoundException: in.wptrafficanalyzer.locationingooglemapv2.MainActivity in loader dalvik.system.PathClassLoader[/data/app/in.wptrafficanalyzer.locationingooglemapv2-1.apk]
        06-19 20:41:05.169: E/AndroidRuntime(32447): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)

  36. osig on August 15, 2013 at 9:50 pm

    Hi sir,your tutorials r very helpful.Is it possible that one user update the map (make a marker on map saying traffic jam on some road ) can be seen to other users using that app too.
    plz help

    • George Mathew on August 15, 2013 at 10:32 pm

      sure you can.

      ( Cloud + Google cloud message ) is a solution for your problem

      Cloud : for updating data in the server

      Google cloud messaging : for informing clients regarding updated data

      • osig on August 16, 2013 at 8:35 pm

        thnx ,can u suggest any tutorial on that.

        • Himanshu on August 16, 2013 at 8:47 pm

          Sir,
          Can u tell me how to update data on map through receiver as getSupportMapFragment is not working in the Receiver

  37. emre on September 30, 2013 at 11:09 pm

    Is it possible adding two or more pipoints to the Map?I thing it’s about OverlayItem ? Please give me example about that.Enjoy yourself.thanks.

  38. vohoangtuit on October 31, 2013 at 6:02 pm

    hi admin & everyone. the TextView no display Location(latitude, longitude). why?

  39. madan singh on November 1, 2013 at 12:14 pm

    Thank you sir it’s really help me thanks a lot……

  40. Dimitrios Michalakis on January 12, 2014 at 5:51 pm

    Hi George, great job sincerely.
    Your app works great but when I move my device i notice that the textview with the current location coordinates does not changes, although my position on the map changes correctly.
    Any solution

  41. PD on January 29, 2014 at 3:20 pm

    Hi George,

    Great work here!!

    I have a doubt .. is it possible to show just the available possible routes to the user? i.e. from Location A to B which possible routes are there. And then when user selects one of the route .. you show the selected route on the Map?

    Does Map API or Direction API allows this?

    • Pearl Malik on April 23, 2014 at 9:21 pm

      Use Directions API. He has an example for that too. Keep the polyline somewhat thick for neatness,

  42. robin on February 13, 2014 at 5:56 pm

    How do i add a marker to current location and keep updating that marker in onlocationchanged to the new location point.

    • Pearl Malik on April 23, 2014 at 9:23 pm

      I think we can add Map as class variable. You can remove marker from map and add a new one again on onlocationchanged() ?

  43. ilias on February 21, 2014 at 7:33 am

    thank you so much George, really appreciate your work!!!
    you help me to solve my research about GPS dvelopment…

Leave a Reply

Your email address will not be published. Required fields are marked *

Be friend at g+

Subscribe for Lastest Updates

FBFPowered by ®Google Feedburner