Android Question retrieve PostString post data into JobDone

Discussion in 'Android Questions' started by Paolo Trevisiol, Jan 10, 2019.

  1. Paolo Trevisiol

    Paolo Trevisiol Member Licensed User

    Hi everyone,

    I used:

    Code:
    Dim myURL As String = "http://www.mysite.com"
    Din szUsr 
    As String = "myself"
    Din szPwd 
    As String = "password"
      
    Dim j As HttpJob
    j.Initialize(
    "MyJob",Me)
    Dim generator As JSONGenerator
    generator.Initialize(CreateMap(
    "Usr": szUsr, "Pwd": szPwd))
    j.PostString(myURL, generator.ToString)
    Could I retrieve "myself" and "password" into sub JobDone if Job.Success = FALSE?
     
    Last edited: Jan 11, 2019
  2. DonManfred

    DonManfred Expert Licensed User

    1. Please use [CODE]code here...[/CODE] tags when posting code.
    2. You can use the Tag from the Job.
    Code:
    Dim j As HttpJob
    j.Initialize(
    "MyJob",Me)
    dim m as map = CreateMap("User":"myself","Password":"password")
    j.Tag = m
    In Jobdone you read the Map back.
    Code:
    dim m as map = job.Tag
     
    jimmyF likes this.
  3. Erel

    Erel Administrator Staff Member Licensed User

  4. Paolo Trevisiol

    Paolo Trevisiol Member Licensed User

    Thanks DonManfred!
    Thanks Erel!

    "Wait For" is correct solution for my project.
     
  5. Paolo Trevisiol

    Paolo Trevisiol Member Licensed User

    Code:
    Sub JobDone(Job As HttpJob)
        
    Dim bRel As Boolean = True
       
        
    If ( Job.JobName == "MyJob" ) Then
            bRel = 
    False ' managed by Wait For
        Else
            
    ' ... managing others jobs ...
        End If
       
        
    If ( bRel ) Then
            Job.Release
        
    End If
    End Sub
    Good code?
     
  6. DonManfred

    DonManfred Expert Licensed User

    No. Using wait for you do not need the sub at all.
    The code should be in the sub where you are using the wait for.
    Code:
    If ( bRel ) Then
            Job.Release
        
    End If
    End Sub
    The job must be ALWAYS released.

    Code:
    Dim myURL As String = "http://www.mysite.com"
    Din szUsr 
    As String = "myself"
    Din szPwd 
    As String = "password"
     
    Dim j As HttpJob
    j.Initialize(
    "MyJob",Me)
    dim m as map = CreateMap("Usr": szUsr, "Pwd": szPwd)
    Dim generator As JSONGenerator
    generator.Initialize(m)
    j.PostString(myURL, generator.ToString)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
       
    Log(j.GetString)
    else
        
    log("User used: "&szUsr)
        
    log("PW used: "&szPwd)
        
    log(j.errormessage)
    End If
    j.Release
     
  7. victormedranop

    victormedranop Well-Known Member Licensed User

    hi, i have tray many ways to postString to and Php script. but no luck.

    i try with soapUI and this is the string generate.

    IMEI=f269ad6583b84f7a0&bateria=10&longi=18.449928&lat=-69.975105&altitud=25&orientacion='N'

    anyone can share with me.

    thanks.

    php code
    Code:
    if (isset($_POST["IMEI"])) {
            $IMEI= $_POST[
    "IMEI"];
            $bateria= $_POST[
    "bateria"];
            $fecha= date(
    "d/m/y H:i:s");
            $longi= $_POST[
    "longi"];
            $lat= $_POST[
    "lat"];
            $altitud= $_POST[
    "altitud"];
            $orientacion= $_POST[
    "orientacion"];
    B4a code1
    Code:
    Dim m As String  = ""
        
    Dim j As HttpJob
        
    Log(m)
        j.Initialize(
    "", Me)
        j.PostString(
    "http://gpstracker.nowyouseeme.net/appmovil/index.php"&$"?IMEI=${public_data.imei}&bateria=10&longi=${public_data.longitude}&lat=${public_data.lattitude}&altitud=${public_data.altitud}&orientacion=N"$ ,m)
        
    Wait For (j) JobDone(j As HttpJob)
        
    If j.Success Then
            
    Log(j.GetString)
        
    End If
        j.Release
    B4a code 2
    Code:
    Dim m As String  = $"?IMEI=${public_data.imei}&bateria=10&longi=${public_data.longitude}&lat=${public_data.lattitude}&altitud=${public_data.altitud}&orientacion=N"$ 
        
    Dim j As HttpJob
        
    Log(m)
        j.Initialize(
    "", Me)
        j.PostString(
    "http://gpstracker.nowyouseeme.net/appmovil/index.php",m)
        
    Wait For (j) JobDone(j As HttpJob)
        
    If j.Success Then
            
    Log(j.GetString)
        
    End If
        j.Release
     
  8. DonManfred

    DonManfred Expert Licensed User

    ... choosen the wrong thread for your question.

    Always create a new thread for your questions instead of posting to another thread.
     
    victormedranop and Peter Simpson like this.
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