Last active
October 7, 2023 16:16
-
-
Save rogergcc/f619cfadfb1a4d0d02cfa0f79b7c8c66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.Manifest; | |
import android.app.Activity; | |
import android.content.pm.PackageManager; | |
import androidx.core.app.ActivityCompat; | |
/** | |
* Created on septiembre. | |
* year 2023 . | |
*/ | |
public class PermissionUtil { | |
public static final int LOCATION_PERMISSION_REQUEST_CODE = 1; | |
public static boolean checkLocationPermission(Activity activity) { | |
int permissionFineLocation = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION); | |
int permissionCoarseLocation = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION); | |
return permissionFineLocation == PackageManager.PERMISSION_GRANTED && permissionCoarseLocation == PackageManager.PERMISSION_GRANTED; | |
} | |
public static void requestLocationPermission(Activity activity) { | |
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, LOCATION_PERMISSION_REQUEST_CODE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment