即時通訊lat和長::|Googlemap和緯度和經度
我該怎麼辦:使用的LocationManager IM爲剛開我的當前位置(我做對話......這給我看加載屏幕在加載
public void onLocationChanged(Location loc)
但..即時通訊設置日誌..或只是一個簡單的消息..我從來沒有得到這個功能的要求。
但是,如果即時通訊使用谷歌地圖片段..在那裏我按下按鈕在右側頂部,它的即時顯示我當前的位置..如何在這種情況下正確? ?如何獲得當前位置(經緯度和長度)?
我只是stucked :(
public class getLocation implements LocationListener
{
public getLocation()
{
dialog = new ProgressDialog(MainActivity.this);
dialog.setMessage("Loading GPS Information");
dialog.setCancelable(true);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.show();
lm = (LocationManager) getSystemService(LOCATION_SERVICE);
new Thread() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
boolean enabled = lm
.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!enabled) {
Toast.makeText(MainActivity.this, "GPS NOT ENABLED" , Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
} else{
Toast.makeText(MainActivity.this, "GPS ENABLED" , Toast.LENGTH_SHORT).show();
if(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER) != null){
Toast.makeText(MainActivity.this, "LAST LOCATION " , Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(MainActivity.this, "Last location unknown ", Toast.LENGTH_SHORT).show();
}
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
0, getLocation.this);
}
}
});
}
}.start();
handler = new Handler() {
public void handleMessage(android.os.Message msg) {
dialog.dismiss();
};
};
}
@Override
public void onLocationChanged(Location loc) {
// TODO Auto-generated method stub =
if(loc!=null){
if(apress){
at.setText("Lat = "+loc.getLatitude()+" | Long = "+loc.getLongitude());
apress=false;
Toast.makeText(MainActivity.this, "OnLocationChanged GPS" , Toast.LENGTH_SHORT).show();
latG=loc.getLatitude();
longG=loc.getLongitude();
showA.setEnabled(true);
handler.sendEmptyMessage(0);
}
}else{
Toast.makeText(MainActivity.this, "OnLocationChanged GPS Location - null" , Toast.LENGTH_SHORT).show();
}
}
@Override
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "ON PROVIDER DISABLED "+arg0 , Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderEnabled(String arg0) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "ON PROVIDER ENABLED "+arg0 , Toast.LENGTH_SHORT).show();
}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
Toast.makeText(MainActivity.this, "ON STATUS CHANGED "+arg0 , Toast.LENGTH_SHORT).show();
}
}
,並在此功能
public void onLocationChanged(Location loc) {
我從來沒有得到正確的調用..它的意思是如果我在這裏加入Log.e(或東西),比它從來沒有顯示:(
你可以添加你的所有課程代碼 – 2014-09-24 13:01:57
hey peter! 如果我正確理解你的問題,你需要從Fragment中刪除「顯示位置按鈕」。 第二件事你想知道你的經緯度和長 – 2014-09-24 13:02:21
@TarunSharma不,我想得到cur LAT和LONG與代碼不在地圖上,我只是不明白爲什麼它不工作,但在地圖上「顯示位置按鈕」,因爲你說 - 這個按鈕總是顯示我在哪裏:(((((我想通過代碼 – Peter 2014-09-24 13:06:24