rog*_*ith 14 android titanium-mobile
我正在使用Titanium的Android 3.2+应用程序.至关重要的是,我能够确定设备是否启用了GPS.根据Titanium API参考,由于新的"被动"位置提供程序,Ti.Geolocation.locationServicesEnabled将始终在Android 2.2+上返回true.有没有其他方法可以确定GPS是否真正启用?
谢谢.
我认为这段代码应该适合你:
//check to see if we have GPS capabilities
if(Titanium.Geolocation.isLocationProviderEnabled(Titanium.Geolocation.PROVIDER_GPS, Titanium.Geolocation.ACCURACY_BEST) == false) {
var alertDlg = Titanium.UI.createAlertDialog({
title:'MileTrackGPS',
message:'GPS is OFF. Enable it in Settings.',
buttonNames: ['Cancel', 'Open Settings']
});
alertDlg.cancel = 0;
alertDlg.addEventListener('click', function(e){
if(!e.cancel) {
//open up the settings page
var settingsIntent = Titanium.Android.createIntent({
action: 'android.settings.LOCATION_SOURCE_SETTINGS'
});
activity.startActivity(settingsIntent);
}
else {
//close the window to exit
win.close();
}
});
alertDlg.show();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3374 次 |
| 最近记录: |