有没有办法找到设备当前配置,如屏幕尺寸和密度,区域设置,区域等......
我正在关注的是在为设备当前配置选择正确的资源时android在运行时所做的事情,但我希望能够从我的服务器下载资源。
有办法吗?我知道我能找到的密度,其余的呢?
答案 0 :(得分:1)
Display d = getWindowManager().getDefaultDisplay();
int h = d.getHeight();
int w = d.getWidth();
// This will give u screen width and height
LocationManager myLocationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
Location myLocation = null;
if(myLocation == null) // if Default Location is Null
{
myLocation = myLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
if(myLocation!=null)
{
String myLatitude = Location.convert(myLocation.getLatitude(), Location.FORMAT_DEGREES);
String myLongitude = Location.convert(myLocation.getLongitude(), Location.FORMAT_DEGREES);
}
// You have to add "android.permission.ACCESS_COARSE_LOCATION" and "android.permission.INTERNET" permissions