Note that there are some explanatory texts on larger screens.

plurals
  1. POI Couldn't Reach Change Location Value in Android
    primarykey
    data
    text
    <p>I'm sorry for mine simple question but I'm newbie this topic. I have Location Class for Android and I reach mine location with Toast Message but I couldn't reach mine location value other class. For example;</p> <p>My Location Class</p> <pre><code>import android.app.AlertDialog; 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 MyLocation{ private LocationManager locationManager; LocationListener locationListener; private Context ourContext; public MyLocation(Context context){ this.ourContext = context; locationManager = (LocationManager) context.getSystemService(context.LOCATION_SERVICE); locationListener = new MyLocationListener(); boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); if(!gps){ locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 6000, 100, locationListener); AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle("GPS Disabled"); alertDialog.setMessage("You can enable GPS for settings"); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.show(); } else { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 6000, 100, locationListener); } } public class MyLocationListener implements LocationListener{ @Override public void onLocationChanged(Location location) { // TODO Auto-generated method stub Bundle bundle = new Bundle(); lat = location.getLatitude(); lon = location.getLongitude(); Toast.makeText(ourContext, lat +" ve "+ lon, Toast.LENGTH_LONG).show(); bundle.putString("lat", lat.toString()); bundle.putString("lon", lon.toString()); } @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 } public String getLat(){ return lat.toString(); } public String getLon(){ return lon.toString(); } private Double lat; private Double lon; } </code></pre> <p>And I call the </p> <pre><code>MyLocation myLocation = new MyLocation(getActivity()); Runnable runnable = new Runnable() { @Override public void run() { // TODO Auto-generated method stub while(bundle.getString("lon") != null){ tv1.setText("Lon : " + bundle.getString("lon")); tv2.setText("Lat : " + bundle.getString("lat")); } } }; new Thread(runnable).start(); </code></pre> <p>But every time my bundle return to null value. What can i do ? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload