使用GPS定位的话,需要如下权限:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
如果使用WIFI接入点定位的话,需要如下权限:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
或者
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
首先使用
LocationManager lm=(LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 1, new TestListener());
获得一个LocationManager ,
requestLocationUpdates的第一个参数为获取定位的方法
LocationManager.GPS_PROVIDER和LocationManager.NETWORK_PROVIDER
第二个参数是最小更新的时间,以秒为单位,为了节省电量,这个值可能比你给的值大或者小
第三个参数是最小距离更新,以米为单位。
第四个参数是一个LocationListener监听器,实现监听器,就可以获得位置。实现监听器的接口
class TestListener implements LocationListener
{
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Toast.makeText(LocationDemoActivity.this, location.getLatitude()+":"+location.getLongitude(), 1000).show();
System.out.println(location.getLatitude()+":"+location.getLongitude());
LocationDemoActivity.this.setTitle(location.getLatitude()+":"+location.getLongitude());
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
}
在这个监听器中就可以获得经纬度,获取了经纬度就知道设备在哪里了。
这里是苹果官方关于实现全屏体验的文档:http://developer.apple.com/library/mac/#documentation/General/Conceptual/MOSXAppProgrammingGuide/FullScreenApp/FullScreenApp.html
1. 实现全屏体验,可以自定义NSWindow,重新实现期初始化方法。
- (id)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)styleMask
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag {
if ([SystemVersion compare:@"10.7.0"] >= 0) {
self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: NO];
}
else {
self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: NO];
}
return self;
}
2. 设置窗口支持全屏体验
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
现象:更新和安装一些软件后,重启,ubuntu10.04LTS登陆桌面无法进入,只有登陆窗口背景色和命令窗口。
鸣谢:有谁碰到过这样的问题,帮忙解决和分享一下,非常感谢。
解决过程:
$sudo apt-get install gdm //无解
$sudo apt-get install ubuntu-desktop //试验中···
说明:问题解决了,重装ubuntu桌面系统($sudo apt-get install ubuntu-desktop ),很完美的修复。
提示:更新软件要注意方法,有的是tar包,需要拷贝文件覆盖系统文件夹,一定注意使用命令的正确性,失误可能导致系统奔溃,浪费很多时间和精力。