Proximity in background at specific distance, combined with showing the travelled route - Android

Hi,

In short, I am making an app which records the decibels and the route the user has walked, to show a heatmap to the user of his/her route on top of the average decibels in each place. So, I want to know on every moment if the user is in a certain region of a certain beacon (and thereby where the user approximately is in the space). This happens while the screen is turned off.

I started with making a proximity-observer (I followed the standard tutorial), and with that everything worked well while the screen of the phone is on. When the screen is off, it does not detect the beacon. Therefore, I want to have the monitoring in the background. However, after looking online and trying many things for three hours, I was not able to solve the problem. It is possible to make sure it monitors in the background, but then I cannot say what the range is (for example, only detect beacon in range of 2.4metres) and this is a problem because I need to know in which specific room the person is.

1.How can I combine monitoring beacons in the background, with more specific distance

When I know which beacons the phone has connected to (what the path of the user was along the beacons). I want to show this path to the user.

2.How can I use the places of the beacons to draw a route on an indoor map, based on the beacons the user was connected to over time (these will be saved in a database, currently Firebase)?

I am using android studio, android level 9, estimate proximity beacons.

Thank you very much in advance.