Continue to launch the application after automatic screen lock - Phonegap (Android / iOS)

I am developing an application that tracks the movement of users on GPS (in particular, on a bicycle), and I realized that when the screen automatically locks, the application will stop working (if I’m not mistaken, I’m not completely determined on this).

Is there a way to prevent the phone from automatically locking? Or as an alternative, is there a way (using Phonegap) to track the movement of the user after automatically locking the screen (like some kind of background process)?

Thanks.

+6
source share
3 answers

I'm sure you need to use Service for this. Services can be started using Activities to start in the background - that is, you can start the Service in the onPause() method of your Activity .

A service is a component that runs in the background to perform lengthy operations or perform work for remote processes. the service does not provide a user interface. For example, a service can play music in the background while the user is in another application, or he can receive data over the network without blocking user interaction with activity. Another component, such as an activity, can start a service and let it start or communicate with it in order to interact with it.

Source: http://developer.android.com/guide/topics/fundamentals.html

Google provides developers with a guide to using Services on the Android developer site. Here's a direct link: http://developer.android.com/guide/topics/fundamentals/services.html

+3
source

You can use service for this.

+1
source

You can add a plugin that will start the service. Add callbacks and methods for the plugin to receive notifications or to receive information. A plugin is basically a communication layer between Cordova / Phonegap and native.

0
source

Source: https://habr.com/ru/post/898074/


All Articles