Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Android Section not clearly describe impact foregroundServiceType=shortService #228

Open
BagasNS opened this issue Jul 1, 2024 · 7 comments · May be fixed by #236
Open

Documentation Android Section not clearly describe impact foregroundServiceType=shortService #228

BagasNS opened this issue Jul 1, 2024 · 7 comments · May be fixed by #236
Labels
documentation Improvements or additions to documentation

Comments

@BagasNS
Copy link

BagasNS commented Jul 1, 2024

i struggling for over 1 day for finding this solution
first i following installation step INSTALL.md everything is good, until my app is crashing after running background process for sometime (about 3-5 minutes)

here is the error
Screenshot 2024-07-01 185152

then i found this documentation from official android page that describe about foregroundServiceType
image

from that documentation i simply change my AndroidManifest.xml from this

  <manifest ... >
    ...
      <application ... >
        ...
        <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="shortService"/>
        ...
      </application>
    ...
  </manifest>

into this

  <manifest ... >
    ...
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/> // adding this permission because im using foregroundServiceType="dataSync"
      <application ... >
        ...
        <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="dataSync"/> // changed to dataSync
        ...
      </application>
    ...
  </manifest>

after that my app is running in background without crashing, i didn't tested it for long time, so i don't know its working forever or not, but it not crashing for 3-5 minutes

so i suggest to update your documentation for android to listing possible value for foregroundServiceType and the impact for each value.

and at the end, thanks for working to build this lib, its awesome!

@Rapsssito
Copy link
Owner

@BagasNS, thanks for the feedback! Could you create a PR with this information so new users also benefit from your discovery?

@Rapsssito Rapsssito added the documentation Improvements or additions to documentation label Jul 9, 2024
@BagasNS BagasNS linked a pull request Jul 29, 2024 that will close this issue
@BagasNS
Copy link
Author

BagasNS commented Jul 29, 2024

Sorry for the delay. I've been busy for the last month, but here we go.

@rajkumarthirumalai
Copy link

rajkumarthirumalai commented Aug 5, 2024

@BagasNS have checked on a lower Android device, such as Android 12. It crashes the same as before and only works properly on Android 14.

@SnehasisSahoo
Copy link

SnehasisSahoo commented Aug 20, 2024

I had a similar issue, that app was crashing after running for 3-5 minutes, 🤦🏾‍♂️ before stumbling upon this issue thread I also had to go through the android docs and changed foreground service type to location as my app is tracking user position in background, would have helped if I searched in issues first 🥲. Great work on the PR @BagasNS, @Rapsssito please merge, it will be really helpful for users.

My change:

  <manifest ... >
    ...
+   <!-- adding this as we use android:foregroundServiceType="location" -->
+   <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
    <application ... >
      ...
-     <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="shortService"/>
+     <!-- adding this as we fetch location in background -->
+     <service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:foregroundServiceType="location"/>
      ...
    </application>
    ...
  </manifest>

Also, I have checked in android 12 and android 14 working well for me in both environments without any issue. @rajkumarthirumalai can you elaborate on your issue?

@vishalyad16
Copy link

@BagasNS I've tried this solution, but it's still crashing

@BagasNS
Copy link
Author

BagasNS commented Sep 3, 2024

@BagasNS I've tried this solution, but it's still crashing

can you give some code to reproduce? you can create new git repository for minimal reproduce, i'll happy to check it out

@Faizan-Hurekatek
Copy link

my app is crashing when im using foregroundServiceType="connectedDevice"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants