Skip to content

Instantly share code, notes, and snippets.

View qichuan's full-sized avatar

Qichuan (Sean) ZHANG qichuan

View GitHub Profile
@qichuan
qichuan / location_request_permission_foreground.kt
Last active July 14, 2021 14:11
android_location_request_foreground
// Request permission
ActivityCompat.requestPermissions(
this@MainActivity,
arrayOf(Manifest.permission.ACCESS_FINE_LOCATION),
REQUEST_FOREGROUND_ONLY_PERMISSIONS_REQUEST_CODE
)
@qichuan
qichuan / AndroidManifest.xml
Created July 14, 2021 13:50
android_location_manifest_android_10
<!-- Specify the permissions that you are using -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Specify the background location permission. -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<!-- Declare a foreground service, if applicable -->
<service
android:name="MyForgroundService"
android:foregroundServiceType="location">
@qichuan
qichuan / location_request_permission_background.kt
Created July 14, 2021 14:10
android_location_request_background
// Request background permission
ActivityCompat.requestPermissions(
this@MainActivity,
arrayOf(Manifest.permission.ACCESS_BACKGROUND_LOCATION),
REQUEST_BACKGROUND_ONLY_PERMISSIONS_REQUEST_CODE
)