关于GPS的问题

T-Quake 2010-09-27 06:50:06
大家好,我最近在调关于GPS的东西,

我搞了个网上的代码 写了个测试程序

import android.app.Activity;
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;

public class CurrentLocation extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager locationManager;
String serviceName = Context.LOCATION_SERVICE;
locationManager = (LocationManager)getSystemService(serviceName);
//String provider = LocationManager.GPS_PROVIDER;

Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = locationManager.getBestProvider(criteria, true);

Location location = locationManager.getLastKnownLocation(provider);
updateWithNewLocation(location);
locationManager.requestLocationUpdates(provider, 2000, 10,
locationListener);
}
private final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
updateWithNewLocation(location);
}
public void onProviderDisabled(String provider){
updateWithNewLocation(null);
}
public void onProviderEnabled(String provider){ }
public void onStatusChanged(String provider, int status,
Bundle extras){ }
};
private void updateWithNewLocation(Location location) {
String latLongString;
TextView myLocationText;
myLocationText = (TextView)findViewById(R.id.myLocationText);
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongString = "纬度:" + lat + "\n经度:" + lng;
} else {
latLongString = "无法获取地理信息";
}
myLocationText.setText("您当前的位置是:\n" +
latLongString);
}
}


可是不知道为什么 怎么总是去调用A-GPS,并且去设置GPRS的东西,可是我不想去走GPRS的A-GPS,而是想走GPS.不知道 是不是接口调用的有问题.
...全文
200 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
T-Quake 2010-09-28
  • 打赏
  • 举报
回复
我看了下android的A-GPS的流程. 是先调用标准API函数,然后去执行/hardware/libXXX/gps/gps.c程序中的一些接口,而这些接口会去调用/vendor/XXX/general/XXX/agps/libgst/XXX.so(驱动代码)

所以每次都会去做A-gps流程的动作,配置什么网络拉等等.

难道需要自己另外实现API?
T-Quake 2010-09-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 liujinrui 的回复:]
Android默认就是A-GPS的,GPS是各厂商自己加的,没有统一的API。
[/Quote]

那就是说需要自己去实现这一套GPS 的API了?
liujinrui 2010-09-28
  • 打赏
  • 举报
回复
Android默认就是A-GPS的,GPS是各厂商自己加的,没有统一的API。

80,488

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧