Will http post requests finish even though app has exit?

LeloLelo Member ✭✭✭

Will http post requests finish even though app has exit on Android and iOS?

Answers

  • batmacibatmaci DEMember ✭✭✭✭✭

    as far as I know, at least I can comment about android(not sure about iOS),it won't. you should create a backgroundtask if you need this to happen in the background when app isn't running.

  • jezhjezh Member, Xamarin Team Xamurai

    Yes, if you want to the http request continue, you can try to create a foreground service to execute the http request in the background when app isn't running.

    Of course, because of Background Location Limits, service is usually killed by system for the following reason:

    In an effort to reduce power consumption, Android 8.0 (API level 26) limits how frequently background apps can retrieve
    the user's current location. Apps can receive location updates only a few times each hour.

    Note: These limitations apply to all apps used on devices running Android 8.0 (API level 26) or higher, regardless of an app's target SDK version.
    However — this doesn’t mean that there is no solution: applications like Google Maps etc still use your location while being on the background, so there has to be a solution. The same page gives you some hints

    The system distinguishes between foreground and background apps. An app is considered to be in the foreground if any of the following is true:

    It has a visible activity, whether the activity is started or paused.
    It has a foreground service.
    Another foreground app is connected to the app, either by binding to one of its services or by making use of one of its content providers. For example, if a foreground app binds to any of the following components within another app, that other app is considered to be in the foreground:
    Input method editor (IME)
    Wallpaper service
    Notification listener
    Voice or text service
    If none of those conditions is true, the app is considered to be in the background.

    So as a solution: create a foreground service!
    For more details: https://hackernoon.com/android-location-tracking-with-a-service-80940218f561
    https://stackoverflow.com/questions/25018051/continue-service-when-app-is-killed

Sign In or Register to comment.