Open Muddasir390 opened 12 months ago
it's not working on android 14, any solution till now?
This is the reason why it doesn't work on Android 14: https://developer.android.com/about/versions/14/changes/fgs-types-required
By adding the necessary configuration, I managed to get it to start on my Android 14 phone. This is what I changed.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
in AndroidManifest.xmlandroid:foregroundServiceType="location"
in the service definitions in AndroidManifest.xmlServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION
The third part is the only thing that actually changed in the library, and that should be somehow updated so it will get the service type from the app... And please note that these changes are to get backround location. For other stuff, different definitions are needed.
ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION was not working for me. I found out that the value of this constant is 8. So you can also use just 8 as third parameter
startForeground(id, notification, 8);
Refrence for above comment: https://developer.android.com/reference/android/content/pm/ServiceInfo#FOREGROUND_SERVICE_TYPE_LOCATION
ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION was not working for me. I found out that the value of this constant is 8. So you can also use just 8 as third parameter
startForeground(id, notification, 8);
The constant should work but you need to import android.content.pm.ServiceInfo;
:) Directly passing the number will of course do the trick as well since it's just a constant defined to make the code more readable.
I tried with a constant value 8 and import android.content.pm.ServiceInfo;
in android 14 but still not working
any solution?
@Pauligrinder you saved our day. Thank you.
@suman379 @Pauligrinder where should add update code please explain detail.i stuck with this issue around couple of weeks
where should add update code please explain detail.i stuck with this issue around couple of weeks
For the library code, you can edit it directly in node_modules/@supersami/rn-foreground-service/android/src/main/java/com/supersami/foregroundservice/ForegroundService.java
, but it will of course be overwritten if you reinstall. The safest way I guess is to fork the whole library, make the change, and then install your own fork from github (or just make a patch with the change, but I'm not familiar with doing that myself)
On a sidenote, if it has taken you several weeks to figure it out even with the help provided here, I think you really should go back to studying RN and Android programming... I mean, it only took me 1-2 hours to figure this out without any help other than the Google-documentation, so it's really not rocket science if you know anything about what you're doing. Sorry for the passive aggressive tone, but it just annoys me very deeply when people don't seem to put any effort into what they're doing.
you can use patch-package package to patch after modification
ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION was not working for me. I found out that the value of this constant is 8. So you can also use just 8 as third parameter
startForeground(id, notification, 8);
can confirm, on a samsung tablet with android 14 i had this line added, but it didn't work at all:
startForeground(id, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION);
then i replaced ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION
with 8
and after that it worked
This solution is not working for me. Do I need something extra besides this?
This solution is not working for me. Do I need something extra besides this?
Did you find out the solution?
This solution is not working for me. Do I need something extra besides this?
Did you find out the solution?
No I didn't 😞
When will servicetype parameter be added to start method? It is necessary
it's not working on android 14