首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android 检察GPS是否开启,GPS设置界面

2012-09-21 
android 检查GPS是否开启,GPS设置界面GPS是否开启LocationManager locationManager (LocationManager)ge

android 检查GPS是否开启,GPS设置界面

GPS是否开启LocationManager locationManager = (LocationManager)getContext().getSystemService(Context.LOCATION_SERVICE);return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);进入GPS设置页面        Intent intent = new Intent();        intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);        try         {            getContext().startActivity(intent);                                        } catch(ActivityNotFoundException ex)         {                        // The Android SDK doc says that the location settings activity            // may not be found. In that case show the general settings.                        // General settings activity            intent.setAction(Settings.ACTION_SETTINGS);            try {                   getContext().startActivity(intent);            } catch (Exception e) {            }        }

热点排行