Android Question Activity change error with HttpJob

Discussion in 'Android Questions' started by Carles Escudé, Jul 28, 2015.

  1. Carles Escudé

    Carles Escudé Member Licensed User

    Hello,

    I have an application using HttpJob and sometimes when I change the activity while it is receiving data it returns to the previuous activity:

    1. On Activity A I ask for some data to the server.
    2. Then, while the data has not yet come I change to the Activity B
    3. Sometimes It begin to change between activities A and B (A-B-A-B-A-B-A-.....) without stopping.

    Is there some method to stop all HttpJob's runnig on one activity?

    Thanks
     
  2. RandomCoder

    RandomCoder Well-Known Member Licensed User

    The best approach is to use a Service Module to run the Http requests in. Within the service you will need to decide what to do when the JobDone event fires. Maybe use a Process Global Variable to store which Activity to call? Maybe you do not need to call any Activity at all but just require some info updating from the Http request? It is difficult to advise further not knowing more about the intended purpose of your App.
     
  3. Carles Escudé

    Carles Escudé Member Licensed User

    But with the Json I received I need to load some objects in the activity (xnGrid, labels,...)
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    The solution is to use a service. From the service you can use CallSub to send the data to the activity if it is currently active (check it with IsPaused). Otherwise get the data from the service when the activity is resumed.
     
Loading...