Hello , 

I have an application where I use GPS and I want while GPS is looking for 
position to display a toast "Waiting for location" and when location is 
found show the location.

To start GPS I press a button:

case R.id.getlocation:
>
gps = new GPSTracker(ShowList.this);
>

// check if GPS enabled

if(gps.canGetLocation()){


latitude = gps.getLatitude();

longitude = gps.getLongitude();



Toast.makeText(getApplicationContext(), "Your Location is \nLat: " + 
latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();



}else{

//show dialog for enabling GPs

gps.showSettingsAlert();

}


Now, with the above it shows "latitude and latitude :0 " because I 
initialize them to 0. 

case R.id.getlocation:
>
gps = new GPSTracker(ShowList.this); 
>
// check if GPS enabled
>
if(gps.canGetLocation()){
>
showToast();
>
}else{
>
   

gps.showSettingsAlert();
>
}
>

> private void showToast() {
>
new Thread() {
>
public void run() {
>
try { 
>
while (message) {
>
runOnUiThread(new Runnable() {
>
@Override
>
public void run() {
>

latitude = gps.getLatitude();

longitude = gps.getLongitude();


Toast.makeText(getApplicationContext(), "Waiting for location", 
Toast.LENGTH_LONG).show();


//}else{

// gps.showSettingsAlert();

// }


}

});

Thread.sleep(1000);

message=false;


} 

} catch (InterruptedException e) {

e.printStackTrace();

}

}

}.start();

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to