title: Updating location in GPS
body: <p>Thank you for your time and help in advance. I am working with location using GPS and only I have gotten the current locations and I have tried to update the values of location, but I haven't had any improvement. Can I ask you how could I update the location? The code is below:</p>
  
  <p>activity.xml:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical" &gt;
          &lt;TextView
                  android:id="@+id/prov"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:text="No provider selected yet"
                  android:layout_marginTop="10dp"
                  android:textSize="20dp" /&gt;
          &lt;TextView
                  android:id="@+id/lat"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="20dp"
                  android:text="Latitude: -"
                  android:textSize="20dp" /&gt;
          &lt;TextView
                  android:id="@+id/lon"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="10dp"
                  android:text="Longitude: -"
                  android:textSize="20dp" /&gt;
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>MainActivity.java:</p>
  
  <pre><code>package com.example.locationservicetest;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.location.Criteria;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.LocationManager;
  import android.os.Bundle;
  import android.provider.Settings;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
        TextView latitude;
        TextView longitude;
        TextView provText;
        LocationManager locationManager;
        String provider;
        MyLocationListener mylistener;
        Criteria criteria;
  
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            latitude = (TextView) findViewById(R.id.lat);
            longitude = (TextView) findViewById(R.id.lon);
            provText = (TextView) findViewById(R.id.prov);
  
            //Get the location manager
            locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);          
  
            //Define the criteria how to select the location provider
            criteria = new Criteria();
            criteria.setAccuracy(Criteria.ACCURACY_FINE);   //default
  
            //Charge of data?
            criteria.setCostAllowed(false);
  
            //Get the best provider depending on the criteria
            provider = locationManager.getBestProvider(criteria, false);
  
            //The last known location of this provider
            Location location = locationManager.getLastKnownLocation(provider);
  
            mylistener = new MyLocationListener();
  
            if (location != null) {
                mylistener.onLocationChanged(location);
            } else {
                //leads to the settings because there is no last known location
                Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                startActivity(intent);
            }
            // location updates: at least 1 meter and 200millsecs change
            locationManager.requestLocationUpdates(provider, 200, 1, mylistener);
        }
  
        private class MyLocationListener implements LocationListener {     
            @Override
            public void onLocationChanged(Location location) {
              // Initialize the location fields
                latitude.setText("New Latitude: "+String.valueOf(location.getLatitude()));
                longitude.setText("New Longitude: "+String.valueOf(location.getLongitude()));
                provText.setText(provider + " provider has been selected.");
  
                Toast.makeText(getBaseContext(),"Location changed!",
                          Toast.LENGTH_SHORT).show();
            }
  
            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {
                Toast.makeText(getBaseContext(), provider + "'s status changed to "+status +"!",
                          Toast.LENGTH_SHORT).show();
            }
  
            @Override
            public void onProviderEnabled(String provider) {
                Toast.makeText(getBaseContext(), "Provider " + provider + " enabled!",
                  Toast.LENGTH_SHORT).show();
  
            }
  
            @Override
            public void onProviderDisabled(String provider) {
                Toast.makeText(getBaseContext(), "Provider " + provider + " disabled!",
                  Toast.LENGTH_SHORT).show();
            }
        }
  }
  </code></pre>
  
  <p>I have changed the AndroidManifest.xml:</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.example.locationservicetest"
      android:versionCode="1"
      android:versionName="1.0" &gt;
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="19" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.example.locationservicetest.MainActivity"
              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;/manifest&gt;
  </code></pre>
  
  <p>The logcat says:</p>
  
  <pre><code>05-20 20:29:40.375: D/ResourcesManager(16834): creating new AssetManager and set to /data/app/com.example.locationservicetest-2/base.apk
  05-20 20:29:40.475: D/Activity(16834): performCreate Call secproduct feature valuefalse
  05-20 20:29:40.475: D/Activity(16834): performCreate Call debug elastic valuetrue
  05-20 20:29:40.495: D/OpenGLRenderer(16834): Render dirty regions requested: true
  05-20 20:29:40.545: I/Adreno-EGL(16834): &lt;qeglDrvAPI_eglInitialize:410&gt;: EGL 1.4 QUALCOMM build:  ()
  05-20 20:29:40.545: I/Adreno-EGL(16834): OpenGL ES Shader Compiler Version: E031.25.01.03
  05-20 20:29:40.545: I/Adreno-EGL(16834): Build Date: 10/28/14 Tue
  05-20 20:29:40.545: I/Adreno-EGL(16834): Local Branch: LA.BF.1.1_RB1_20141028_021_patches2
  05-20 20:29:40.545: I/Adreno-EGL(16834): Remote Branch: 
  05-20 20:29:40.545: I/Adreno-EGL(16834): Local Patches: 
  05-20 20:29:40.545: I/Adreno-EGL(16834): Reconstruct Branch: 
  05-20 20:29:40.545: I/OpenGLRenderer(16834): Initialized EGL, version 1.4
  05-20 20:29:40.565: I/OpenGLRenderer(16834): HWUI protection enabled for context ,  &amp;this =0xafb22088 ,&amp;mEglDisplay = 1 , &amp;mEglConfig = 8 
  05-20 20:29:40.565: D/OpenGLRenderer(16834): Enabling debug mode 0
  05-20 20:29:40.655: I/Timeline(16834): Timeline: Activity_idle id: android.os.BinderProxy@16c2c9f9 time:221858392
  </code></pre>
  
  <p>I appreciate your guidance, help and time. Thank you.</p>