即时通讯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