zoukankan      html  css  js  c++  java
  • 2 GPS utility methods

    Methond 1 is to check whether the GPS is on:

    1
    2
    3
    4
    5
    
    public boolean isGPSIsOn() {
    	LocationManager locationManager = (LocationManager) mContext
    			.getSystemService(Context.LOCATION_SERVICE);
    	return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    }
    

    Method 2 is to open GPS setting page in Android device:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    public void openGPSSettingPage() {
    	Intent intent = new Intent();
    	intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    	try {
    		context.startActivity(intent);
    	} catch (ActivityNotFoundException ex) {
    	}
    }

    Codes in Github : https://gist.github.com/Viyu/9406327

  • 相关阅读:
    bzoj1221
    hdu3377
    bzoj3930
    bzoj3976
    bzoj4237
    fzu1977
    hdu1693
    ural1519
    bzoj1264
    回答自己的提问
  • 原文地址:https://www.cnblogs.com/mosthink/p/5288928.html
Copyright © 2011-2022 走看看