I am running a shinyMobile app (on an Android smartphone, using the internal browser, running on shinyapps.io) using the leaflet.extras package to retrieve GPS location data. That is working fine, as long as the screen is turned on.
When the screen is turned off, no further locations are checked.
When I turn again the screen on, the process continues to run without issues.
Is there a way to continue monitoring the GPS location with screen turned off?
The code:
library(leaflet)
library(leaflet.extras)
library(shiny)
library(shinyMobile)
ui <- f7Page(
title = "Tracker",
f7SingleLayout(
navbar = f7Navbar(title = "Tracker"),
leafletOutput('map'),
tableOutput("table")
)
)
server <- function(input, output, session) {
# track df creation
track <- reactiveValues(pos=data.frame(matrix(ncol = 3,
nrow = 0)),count =1)
# creating df for a single point
newpos <- reactive({
data.frame(
id = track$count,
lon = input$map_gps_located$coordinates$lng,
lat = input$map_gps_located$coordinates$lat)
})
# adding a point to the track
storedValues <- observeEvent(input$map_gps_located$coordinates, {
track$pos <- rbind(track$pos, newpos())
track$count <- track$count +1
})
# track
output$table <- renderTable({track$pos})
#plotting the map
output$map <- renderLeaflet({
leaflet()%>%
addTiles() %>%
addControlGPS(options = gpsOptions(position = "topleft", activate = TRUE,
autoCenter = TRUE, maxZoom = 60,
setView = TRUE))
})
}
shinyApp(ui, server)
question from:
https://stackoverflow.com/questions/65647454/how-to-keep-running-a-shinymobile-app-on-a-smartphone-with-turned-off-screen 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…