GPS获取当前的经度和纬度
来源:互联网 发布:手机做模卡的软件 编辑:程序博客网 时间:2024/04/30 04:04
package com.cn.gps;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;
public class GpsActivity extends Activity {
/** Called when the activity is first created. */
private TextView text;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
text = (TextView)findViewById(R.id.tv1);
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
showLocation(location);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 10, new LocationListener(){
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
showLocation(location);
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
showLocation(null);
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
showLocation(locationManager.getLastKnownLocation(provider));
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
});
}
public void showLocation(Location currentLocation){
if(currentLocation != null){
String s = "";
s += "当前位置: (";
s += currentLocation.getLongitude();
s += ",";
s += currentLocation.getLatitude();
s += ")\n 速度: ";
s += currentLocation.getSpeed();
s += "\n 方向: ";
s += currentLocation.getBearing();
s +="\n 高度:";
s += currentLocation.getAltitude();
text.setText(s);
}
else{
text.setText("");
}
}
}
- GPS获取当前的经度和纬度
- Android 获取地理位置的经度和纬度
- Android 获取地理位置的经度和纬度
- Android 获取地理位置的经度和纬度
- Android获取经度和纬度
- iOS. 原生获取当前经度 纬度。 地址
- Android 自带 获取地理位置的经度和纬度
- 腾讯地图获取地址的经度和纬度
- 006-实现Unity3d获取设备的GPS信息(经度纬度信息)
- 根据地址获取经度和纬度
- GPS 经度纬度 坐标转换的以色列横轴墨卡托投影(ITM)
- google地图获取经度、纬度
- google地图获取经度、纬度
- 根据地址获取经度纬度
- 根据地址获取经度纬度
- HTML5手机浏览器获取经度和纬度(百度API)
- 通过浏览器geolocation属性获取经度和纬度(1)
- 一个点的经度和纬度,以这个点为圆心,1000米为半径,最大的经度和纬度,最小的经度和纬度
- EL表达式详解
- C#之线程、委托,强强联手操作窗体控件...
- 关于phoneGap camera照片放置的位置问题
- Android 显示系统
- 获取管理Android源代码中各个git仓库的xml配置文件
- GPS获取当前的经度和纬度
- 设置为顶层窗口
- jsp在ie6中css的margin属性失效问题
- Unicode字段也有collation
- 工作记录之spi调试记录
- Android传感器介绍
- VC结构体边界对齐
- 记录的开始
- Sencha Touch2中数据的获取