Skip to content

sample for Get location in the background(Android 10 or later)

Notifications You must be signed in to change notification settings

LeoAndo/LocationUpdateBackgroundSample

Repository files navigation

Overview

日本語版ReadMeはこちら!

Sample project for background location acquisition on Android 10 and above

It is better to get location information with the foreground service

If the app wants to get location information in the background from Android 10, it needs permission of ACCESS_BACKGROUND_LOCATION.

However, when handling location information in the foreground service, it is possible to acquire location information without requiring permission for ACCESS_BACKGROUND_LOCATION. In that case, you need to specify location in [foregroundServiceType] (https://developer.android.com/reference/android/R.attr#foregroundServiceType) of the foreground service.

link1 link2 link3 link4 link5 link6 link7 link8

Check if you can get location information in the foreground / background of the app

device foreground background
Pixel 4 OS:13
Pixel 4 OS:12 OK OK
Pixel 4 OS:10 OK OK

capture Pixel 4 OS:10

Screen Notification

capture Pixel 4 OS:12

Screen Notification

capture Pixel 4 OS:13

Screen Notification

implements memo

foreground service

background

From Android 10, the item "Allow only while using the app" has been added to the selection items on the app settings screen.

If "Allow only while using the app" is checked, location information in the background will not be performed.

About

sample for Get location in the background(Android 10 or later)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages