Android: location not changing in google map
<p>I would like to develop an application for people tracking by using GPS tracker device in order to send the coordinates (Latitude and Longitude) via SMS to android phone and bring the coordinates values to display the accurate location on Google Map.</p>

<p>Here is Manifest:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android"
    android:versionCode="1"
    android:versionName="1.0"&gt;
&lt;uses-sdk android:minSdkVersion="10" /&gt;
&lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
&lt;uses-library android:name="com.google.android.maps" /&gt;
    &lt;activity android:name=".MapTestActivity"
              android:label="@string/app_name"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;
            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
&lt;/application&gt;
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
    &lt;uses-permission android:name="android.permission.SEND_SMS" /&gt;
    &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
&lt;/manifest&gt;
</code></pre>

<p>Here is my code:</p>

<pre><code>package com.google.android;

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.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import android.widget.ZoomControls;

public class MapTestActivity extends MapActivity {
    /** Called when the activity is first created. */
    private MapView mapView;
    private MapController mapController;
    private Button btnSatelite;
    private Button btnStreet;
    private ZoomControls zoomControls;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        btnSatelite = (Button)findViewById(R.id.btnSatelite);
        btnSatelite.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
            // TODO Auto-generated method stub
                mapView.setTraffic(false);
                mapView.setSatellite(true);
            }
        });     
        btnStreet = (Button)findViewById(R.id.btnStreet);
        btnStreet.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            // TODO Auto-generated method stub
                mapView.setSatellite(false);
                mapView.setTraffic(true);
            }
        });     
        zoomControls = (ZoomControls)findViewById(R.id.zoomControls1);
        zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mapController.zoomIn();
            }
        });
        zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 mapController.zoomOut();
             }
        });
        mapView = (MapView)findViewById(R.id.mapview1);
        mapController = mapView.getController();

        class SMSReceiver extends BroadcastReceiver {

            public double dLat;
            public double dLng;

            @Override
            public void onReceive(Context context, Intent intent) {
                //---get the SMS message passed in---
                Bundle bundle = intent.getExtras();        
                SmsMessage[] msgs = null;
                String position1 = "";            
                if (bundle != null) {
                    //---retrieve the SMS message received---
                    Object[] pdus = (Object[]) bundle.get("pdus");
                    msgs = new SmsMessage[pdus.length];            
                    for (int i=0; i&lt;msgs.length; i++) {
                        msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);             
                        position1 += msgs[i].getMessageBody().toString();       
                    }
                    String position2 = position1.substring(position1.indexOf(" ")+1, position1.length());
                    String lat = position1.substring(position1.indexOf(":")+1, position1.indexOf(" "));
                    String lng = position2.substring(position2.indexOf(":")+1, position2.indexOf(" "));
                    dLat = Double.parseDouble(lat);
                    dLng = Double.parseDouble(lng);
                    //---display the new SMS message---
                    //Toast.makeText(context, position1, Toast.LENGTH_SHORT).show();

                    GeoPoint point = new GeoPoint((int) (dLat * 1E6),(int) (dLng * 1E6));
                    mapController.animateTo(point);
                    mapController.setZoom(18);
                    mapView.invalidate();   
                }
            }
        }
    }

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

<p>Each message has the following characteristics:</p>

<blockquote>
  <p>lat:??? long: speed:??? T:??? Bat: ??? Lac:???,???</p>
</blockquote>

<p>example:</p>

<blockquote>
  <p>lat:14.0228 long:99.9759 speed:100.00 T:10.45 Bat: 86% Lac:F551,5B97</p>
</blockquote>

<p>I want only the value of lat(latitude) and long(longitude). So, I use SMSReceiver class to get SMS then do the substring and convert the coordinates values (text form) which are string to be double, it works as follows</p>

<p>Step 1: get SMS.<br>
Step 2: extract message from array to position1.<br>
Step 3: Do substring text message</p>

<blockquote>
  <p>position1 = lat:14.0228 long:99.9759 speed:100.00 T:10.45 Bat: 86% Lac:F551,5B97</p>
  
  <p>position2 = long:99.9759 speed:100.00 T:10.45 Bat: 86% Lac:F551,5B97</p>
</blockquote>

<p>Step 4: Do substring to get lat and lng values (string values)</p>

<blockquote>
  <p>lat = 14.0228</p>
  
  <p>lng = 99.9759</p>
</blockquote>

<p>Step 5: convert string values to double values (double values)</p>

<blockquote>
  <p>dLat = 14.0228</p>
  
  <p>dLng = 99.9759</p>
</blockquote>

<p>Step 6: use dLat and dLng values for </p>

<blockquote>
  <p>GeoPoint point = new GeoPoint((int) (dLat * 1E6),(int) (dLng * 1E6));</p>
</blockquote>

<p>The position should be changed according to the coordinates, but after I get the coordinate values from SMS, there is no location changing displayed on the map. I suppose that it may be because of SMSReceiver class which cannot refer the coordinate values from SMSReceiver class. Please give me some advice what should I do to solve this problem.</p>

<p>Thanks for the answers. </p>
