Android三種GSM手機(jī)技術(shù)分析
更新時(shí)間:2012年12月05日 15:05:01 投稿:whsnow
本文將詳細(xì)介紹Android三種GSM技術(shù)比較差別,有感興趣的朋友可以參考下
復(fù)制代碼 代碼如下:
// 聲明LocationManager對(duì)象
LocationManager loctionManager;
// 通過(guò)系統(tǒng)服務(wù),取得LocationManager對(duì)象
loctionManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
方式一:
復(fù)制代碼 代碼如下:
// 通過(guò)GPS位置提供器獲得位置
String providerGPS = LocationManager.GPS_PROVIDER;
Location location = loctionManager.getLastKnownLocation(providerGPS);
方式二:
復(fù)制代碼 代碼如下:
// 通過(guò)基站位置提供器獲得位置
String providerNetwork = LocationManager.NETWORK_PROVIDER;
Location location = loctionManager.getLastKnownLocation(providerNetwork);
方式三:
復(fù)制代碼 代碼如下:
// 使用標(biāo)準(zhǔn)集合,讓系統(tǒng)自動(dòng)選擇可用的最佳位置提供器,提供位置
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);// 高精度
criteria.setAltitudeRequired(false);// 不要求海拔
criteria.setBearingRequired(false);// 不要求方位
criteria.setCostAllowed(true);// 允許有花費(fèi)
criteria.setPowerRequirement(Criteria.POWER_LOW);// 低功耗
// 從可用的位置提供器中,匹配以上標(biāo)準(zhǔn)的最佳提供器
String provider = loctionManager.getBestProvider(criteria, true);
// 獲得最后一次變化的位置
Location location = loctionManager.getLastKnownLocation(provider);
處理:
復(fù)制代碼 代碼如下:
// 顯示在EditText中
updateWithNewLocation(location);
private final LocationListener locationListener = new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
// 當(dāng)位置變化時(shí)觸發(fā)
@Override
public void onLocationChanged(Location location) {
// 使用新的location更新TextView顯示
updateWithNewLocation(location);
}
};
private void updateWithNewLocation(Location location) {
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
latStr = format.format(lat);
lonStr = format.format(lng);
txtLat.setText(latStr);
txtLon.setText(lonStr);
} else {
txtLat.setText("");
txtLon.setText("");
}
}
相關(guān)文章
Android進(jìn)度條控件progressbar使用方法詳解
這篇文章主要為大家詳細(xì)介紹了Android進(jìn)度條控件progressbar的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08android dialog背景模糊化效果實(shí)現(xiàn)方法
這篇文章主要為大家詳細(xì)介紹了android dialog背景模糊化效果的實(shí)現(xiàn)方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04Android開發(fā)使用strings.xml多語(yǔ)言翻譯解決方案
這篇文章主要為大家介紹了Android開發(fā)使用strings.xml多語(yǔ)言翻譯解決方案,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06Android利用懸浮按鈕實(shí)現(xiàn)翻頁(yè)效果
這篇文章主要介紹了Android利用懸浮按鈕實(shí)現(xiàn)翻頁(yè)效果的相關(guān)資料,需要的朋友可以參考下2015-12-12android實(shí)現(xiàn)音樂跳動(dòng)效果的示例代碼
這篇文章主要介紹了android實(shí)現(xiàn)音樂跳動(dòng)效果的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04詳細(xì)講解AsyncTask使用說(shuō)明(值得收藏)
AsyncTask就相當(dāng)于Android給我們提供了一個(gè)多線程編程的一個(gè)框架,其介于Thread和Handler之間,我們?nèi)绻x一個(gè)AsyncTask,就需要定義一個(gè)類來(lái)繼承AsyncTask這個(gè)抽象類,并實(shí)現(xiàn)其唯一的一doInBackgroud 抽象方法,這篇文章主要介紹了AsyncTask詳解,需要的朋友可以參考下2024-01-01Android使用Matrix旋轉(zhuǎn)圖片模擬碟片加載過(guò)程
這篇文章主要為大家詳細(xì)介紹了Android使用Matrix旋轉(zhuǎn)圖片模擬碟片加載過(guò)程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03ProtoBuf動(dòng)態(tài)拆分Gradle?Module解析
這篇文章主要為大家介紹了ProtoBuf動(dòng)態(tài)拆分Gradle?Module解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02