Ⅰ android開發,手機獲取 GPS位置信息,求助手機睡眠以後獲取GPS位置信息
一直搜索gps是因為無法定位。一般國產手機的gps晶元型號不行(用的晶元是集成在手機主晶元上的),搜星速度慢,無法定位。我用三星的手機不用開a-gps都能一分鍾搜到信號定位成功。但用中興的手機就不行,用a-gps經常是5分鍾以上才能定位。另外高速移動也影響定位計算。還有手機會保存上次定位的一些信息,這樣在下次開gps時定位更快,你在高速上開gps,換了新地方計算定位花的時間會更長。建議你改改手機里的設置,換一個a-gps的定位網路伺服器地址。
Ⅱ android的怎麼使用gps定位
有兩種方法,
一種是設置里,有個位置和安全的選項,裡面設置允許使用位置服務;
第二種(安卓4.0以上)在下拉欄里點擊「位置服務」案件,綠色就表示打開了。以上兩種方法使用時都會在上面有一個位置服務標識中間在閃爍。
打開wifi和GPS,允許定位!
Ⅲ Android 怎樣穩定的獲取原生GPS數據
定位了就有經緯度,沒定位,則一直閃的;
一般是4個星的時候 會定位。
所以可以根據是否獲取有效的經緯度信息來判斷是否定位。
衛星的個數 sv_status也是可以通過API獲取的。LOCATION類
給你一段我的代碼,看看就知道了。
locationManager.addGpsStatusListener(statusListener);//偵聽GPS狀態
private GpsStatus.Listener statusListener = new GpsStatus.Listener()
{
public void onGpsStatusChanged(int event)
{
// TODO Auto-generated method stub
GpsStatus gpsStatus= locationManager.getGpsStatus(null);
Log.v(TAG,"GPS status listener ");
//Utils.DisplayToastShort(GPSService.this, "GPS status listener ");
switch(event)
{
case GpsStatus.GPS_EVENT_FIRST_FIX:{
//第一次定位時間UTC gps可用
//Log.v(TAG,"GPS is usable");
int i=gpsStatus.getTimeToFirstFix();
Utils.DisplayToastShort(GPSService.this, "GPS 第一次可用 "+i);
Utils.setGPSStatus(Utils.GPS_STATUS.START);
break;
}
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:{//周期的報告衛星狀態
//得到所有收到的衛星的信息,包括 衛星的高度角、方位角、信噪比、和偽隨機號(及衛星編號)
Iterable<GpsSatellite> allSatellites;
allSatellites = gpsStatus.getSatellites();
Iterator<GpsSatellite>iterator = allSatellites.iterator();
int numOfSatellites = 0;
int maxSatellites=gpsStatus.getMaxSatellites();
while(iterator.hasNext() && numOfSatellites<maxSatellites){
numOfSatellites++;
iterator.next();
}
Log.v(TAG,"GPS is **unusable** "+ numOfSatellites +" "+ maxSatellites);
if( numOfSatellites < 3){
// Utils.DisplayToastShort(GPSService.this, "***衛星少於3顆***");
Utils.setGPSStatus(Utils.GPS_STATUS.STOP);
} else if(numOfSatellites > 7){
Utils.setGPSStatus(Utils.GPS_STATUS.START);
}
break;
}
case GpsStatus.GPS_EVENT_STARTED:{
//Utils.DisplayToastShort(GPSService.this, "GPS start Event");
break;
}
case GpsStatus.GPS_EVENT_STOPPED:{
//Utils.DisplayToastShort(GPSService.this, "GPS **stop*** Event");
Utils.setGPSStatus(Utils.GPS_STATUS.STOP);
break;
}
default :
break;
}
}
};
Ⅳ 如何在Android中編程獲得當前的GPS定位
您好,很高興為您解答。
一、准備工作需要如下三種軟體:1. Eclipse2. Android SDK3. 開發Android程序的Eclipse 插件
為了開始我們的工作,首先要安裝Eclipse,然後從Google的網站獲得Android SDK,並且安裝Eclipse插件。
二、Activity類每一種移動開發環境都有自己的基類。如J2ME應用程序的基類是midlets,BREW的基類是applets,而Android程序的基類是 Activity。這個activity為我們提供了對移動操作系統的基本功能和事件的訪問。這個類包含了基本的構造方法,鍵盤處理,掛起來恢復功能,以 及其他底層的手持設備的訪問。實質上,我們的應用程序將是一個Activity類的擴展。在本文中讀者將會通過例子學習到如何使用Activity類來編 寫Android程序。
Ⅳ android如何獲取地理位置
三種方式進行定位,獲取用戶位置,分別是基於基站定位, 網路定位,GPS定位。
1.基站定位(passive):這是基於網路基站進行定位的,定位的精確度在幾十米到幾千米不等,在城市中基站覆蓋率比較高,推薦使用基站定位,如果是在郊區,基站相距較遠,基站的覆蓋沒有城裡好,定位的誤差比較大。如果在郊區不推薦使用基站定位。
2.網路定位:wifi定位,網路定位
3.GPS定位:與衛星進行通信。手機中嵌入了GPS模塊(精簡版的A-GPS),通過A-GPS搜索衛星, 獲取經緯度。使用GPS的弊端是:必須站在空曠的地方,頭頂對著天空,如果雲層厚了,也會受到一定的影響。精確度:10-50米
擴展知識:
使用Android是定位必備的許可權:
< uses-permission android:name= " android.permission.ACCESS_FINE_LOCATION " /> //精確定位
<uses-permission android:name= "android.permission.ACCESS_MOCK_LOCATION" /> //模擬器
<uses-permission android:name= "android.permission.ACCESS_COARSE_LOCATION" /> //粗糙定位
//獲取定位管理對象
LocationManager lm=(LocationManager)getSystemService(LOCATION_SERVICE);
String[] names=lm.getAllProviders();//獲取所有的位置提供者,一般三種
Criteria criteria=new Criteria();//查詢條件,如果設置了海拔,則定位方式只能是GPS;
criteria.setCostAllowed(true);//是否產生開銷,比如流量費
String provider=lm.getBaseProvider(criteria,true)//獲取最好的位置提供者,第二個參數為true,表示只獲取那些被打開的位置提供者
lm.requestLocationUpdates(provier,0,0,new LocationListener(){});//獲取位置。第二個參數表示每隔多少時間返回一次數據,第三個參數表示被定位的物體移動每次多少米返回一次數據。
private class MyLocationListener implements LocationListener {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
@Override
public void onLocationChanged(Location location) {
System. out.println( "服務中位置監聽發送了變化了" );
float accuracy = location.getAccuracy(); // 精確度
double altitude = location.getAltitude(); // 海拔
double latitude = location.getLatitude(); // 緯度
double longitude = location.getLongitude(); // 經度
String locationInfo = "jing:" + longitude + ",wei:" + latitude + ",haiba:" + altitude + ",jingque:" + accuracy;
Editor edit = sp.edit();
edit.putString( "location", locationInfo);
edit.commit();
}
} public void onProviderDisabled(String provider) {
}
Ⅵ android 怎麼獲取gps信息
可以做到直接call到GPS模塊,讀取當前的經緯度。
但經緯度->實際地址的轉換,google提供了api供程序調用,需要去申請一個google maps api的key,然後發送經緯度,會返回實際地址。
Ⅶ Android 怎樣穩定的獲取原生GPS數據
LocationManager類的對象獲取由系統提供
為一個LocationManager對象建立一個對象引用
Ⅷ 安卓手機怎麼定位 安卓手機怎麼打開定位
可參考vivo手機的開啟方式:
1、可以進入設置--(安全與隱私/更多設置)--定位服務--開啟「定位服務/使用GPS衛星」,開啟後可選擇軟體開啟定位許可權;
2、打開手機的控制中心--點擊定位按鈕即可開啟。
Ⅸ 安卓手機如何開啟GPS定位服務
1、首先打開自己的手機,然後找到設置圖標,點擊進入。
Ⅹ android怎樣獲得gps信息
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
private void getLocation()
{
// 獲取位置管理服務
LocationManager locationManager;
String serviceName = Context.LOCATION_SERVICE;
locationManager = (LocationManager) this.getSystemService(serviceName);
// 查找到服務信息
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); // 獲取GPS信息
Location location = locationManager.getLastKnownLocation(provider); // 通過GPS獲取位置
updateToNewLocation(location);
// 設置監聽器,自動更新的最小時間為間隔N秒(1秒為1*1000,這樣寫主要為了方便)或最小位移變化超過N米
locationManager.requestLocationUpdates(provider, 100 * 1000, 500,
locationListener); }
private void updateToNewLocation(Location location) {
TextView tv1;
tv1 = (TextView) this.findViewById(R.id.tv1);
if (location != null) {
double latitude = location.getLatitude();
double longitude= location.getLongitude();
tv1.setText("維度:" + latitude+ "\n經度" + longitude);
} else {
tv1.setText("無法獲取地理信息");
}
}
網路地圖API調用地址:http://api.map..com/geocoder?output=json&location=緯度,經度&key=APP_KEY
谷歌地圖服務API調用地址:http://maps.google.com/maps/api/geocode/json?latlng= 緯度,經度 &language=zh-CN&sensor=true
可以設置返回數據格式,JSON或者XML。