gps打开接口

来源:互联网 发布:淘宝网电脑旺旺打不开 编辑:程序博客网 时间:2024/06/06 01:26

android判断gps是否打开的接口:

    public boolean isGpsOpen(Context context) {        return Settings.Secure.isLocationProviderEnabled(context.getContentResolver(),            android.location.LocationManager.GPS_PROVIDER);    }

android中打开gps的接口:

同时需要<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>权限

    public static void enableGps(Context context, boolean enable) {        try {Settings.Secure.setLocationProviderEnabled(context.getContentResolver(), LocationManager.GPS_PROVIDER,        enable);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}    }


0 0
原创粉丝点击