Android Question Best Solution for create a library to use HttpJob

Discussion in 'Android Questions' started by Alberto Iglesias, Jun 19, 2019.

  1. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    Hello everyone,

    I will create some library .b4xlib to make requests to make life easy on both platforms.

    What's the best solution for create this?

    In my mind, I think for to this is create a service on .b4xlib for B4A and Module for B4i, is that better option?

    Code:
    Dim j As HttpJob
    j.Initialize(
    "", Me)
    j.Download(strEndpoint)
           
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
    End If
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Use OkHttpUtils2...

    The code you posted is very simple. I don't see how putting it in a library will make things simpler.
     
  3. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    Because we have some code sharing for both platforms and supose you have a method in this shared code to get informations from webservice.

    for B4i is OK, you can put on the same shared code (module), but for B4A you need a activity to get the response.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    No you don't.

    Best way to share this code is to put it in a class that is initialized from the starter service in B4A.
     
  5. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    Exactly, but B4i dont have a service, this is my question
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    The goes into the class, not the service.
     
  7. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    Great! And thinking about this class, do you know if is a good idea to create a .b4xlib with this for using on both platforms?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    klaus likes this.
  9. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    OK got it! thanks @Erel
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice