react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Getting issue in fetching location when device screen is locked Android

Open GurjeetLamba opened this issue 2 years ago • 7 comments
trafficstars

Your Environment

  • Plugin version:0.6.3

  • Platform: Android

  • OS version: 12

  • Device manufacturer and model: OPPO CPH2095

  • React Native version: 0.64

  • Plugin configuration options: BackgroundGeolocation.configure({ desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY, stationaryRadius: 50, distanceFilter: 50, notificationTitle: 'Background tracking', notificationText: 'enabled', debug: true, startOnBoot: false, stopOnTerminate: true, locationProvider: BackgroundGeolocation.RAW_PROVIDER, interval:50000, fastestInterval: 50000, activitiesInterval: 50000, stopOnStillActivity: false, url: 'http://192.168.81.15:3000/location', httpHeaders: { 'X-FOO': 'bar' },

    postTemplate: {
      lat: '@latitude',
      lon: '@longitude',
      foo: 'bar' // you can also add your own properties
    }
    

    });

Context

I am trying to get the location all the time , whether device locked or unlocked , app in foreground or background , I have taken the background Permissions also , but not getting correct location when device is locked. I am not using the url but calling the API after getting location

Steps to Reproduce

  1. open the app or close keep device screen lock 15 seconds and let the device lock itself
  2. location will not be saved in db

GurjeetLamba avatar Jun 21 '23 08:06 GurjeetLamba

did you face some build errors

jagatrajsingh2000 avatar Jul 04 '23 10:07 jagatrajsingh2000

no

GurjeetLamba avatar Jul 04 '23 10:07 GurjeetLamba

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'. Could not find ::. Required by: project :app

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

jagatrajsingh2000 avatar Jul 04 '23 11:07 jagatrajsingh2000

did you face this error ?

jagatrajsingh2000 avatar Jul 04 '23 11:07 jagatrajsingh2000

@jagatrajsingh2000 Hello, did you get a solution?

GusttavoCastilho avatar Aug 09 '23 22:08 GusttavoCastilho

Got any solution for this?

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'. Could not find ::. Required by: project :app

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Linuhusainnk avatar Feb 19 '24 02:02 Linuhusainnk

To solve the problem add this in your AndroidManifest

<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

and add this services in the same file

<service android:name=".floatingview.FloatingViewService" android:foregroundServiceType="location" android:exported="false" />

That fix my problem

bmarbello avatar Sep 17 '24 20:09 bmarbello