編輯:關於Android編程
[java]
public void getAndRefreshLocation(GeoPoint p) {
try {
LogUtil.i("ReviewPositionUI", "Lat==" + p.getLatitudeE6() + "==Long==" + p.getLongitudeE6());
double lat = (double)p.getLatitudeE6()/1000000;
double lon = (double)p.getLongitudeE6()/1000000;
LogUtil.i("ReviewPositionUI", "Lat==" + lat + "==Long==" + lon);
List<Address> address = mGeocoder.getFromLocation(lat,
lon, 3);
if (address != null) {
Address addres = address.get(0);
String addressName = addres.getAdminArea()
+ addres.getSubLocality() + addres.getFeatureName()
+ "附近";
Toast.makeText(mContext, addressName, Toast.LENGTH_LONG).show();
}
} catch (AMapException e) {
LogUtil.i("ReviewPositionUI", e.getMessage());
}
}
[java]
public class GPSLocation {
private LocationManagerProxy mLocationManager;
private Context mContext;
LocationManager mManager;
public GPSLocation(Context context) {
this.mContext = context;
mLocationManager = LocationManagerProxy.getInstance(context);
mManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
}
public void enableMyLocation(LocationListener listener) {
Location location;
if (NetworkState.TYPE_WIFI == NetworkState.searchNetworkType(mContext)){
location = mManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}else{
location = mManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
}
if (location != null){
listener.onLocationChanged(location);
}else{
Criteria cri = new Criteria();
cri.setAccuracy(Criteria.ACCURACY_COARSE);
cri.setAltitudeRequired(false);
cri.setBearingRequired(false);
cri.setCostAllowed(false);
String bestProvider = mLocationManager.getBestProvider(cri, true);
try{
mLocationManager.requestLocationUpdates(bestProvider, 2000, 10, listener);
}catch (Exception e){
listener.onLocationChanged(null);
} www.2cto.com
}
}
public void disableMyLocation(LocationListener listener) {
if (mLocationManager != null){
mLocationManager.removeUpdates(listener);
mLocationManager.destory();
mLocationManager = null;
}
if (mManager != null){
mManager.removeUpdates(listener);
}
}
}
一. 彩信發送: 彩信比短信麻煩很多。從sendMmsWorker函數的參數就可以看出來:(conv, mmsUri, persister, slidesho
我們在平時做開發的時候,免不了會用到各種各樣的對話框,相信有過其他平台開發經驗的朋友都會知道,大部分的平台都只提供了幾個最簡單的實現,如果我們想實現自己特定需求的對話框,
在開發中UI布局是我們都會遇到的問題,隨著UI越來越多,布局的重復性、復雜度也會隨之增長。Android官方給了幾個優化的方法,但是網絡上的資料基本上都是對官方資料的翻
之前關於如何實現屏幕頁面切換,寫過一篇博文《Android中使用ViewFlipper實現屏幕切換》,相比ViewFlipper,ViewPager更適用復雜的視圖切換,