png image via JSON

roarnold

Active Member
Licensed User
Longtime User
I am trying to figure out why I receive a parent/child Java exception error which started when I added to more items to the string passed from a backend SQL server. These two files are .png files (one for the sales company and the other for the purchasing company). I tried setting up WebView, ImageView in designer as well as declaring the vairable as both of those
along with Object.

I parse the string and it shows in the string and when it gets to the initialization of the variable and the .png is place in the variable it has the hyperlink with the .png image. When I run the app I get a Java Exception Parent Child issue.

You will notice two activities. Thr first one is for getting information from the user and the second is for a splash screen and presenting the information requested in a particular layout. I am only having an issue with the .png images. Everything else look great. You will notice I commented out a couple items which I will introduce later as they get into the backend.

Appreciate any help. Thanks Ron




'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim hc As HttpClient
Dim URL As String
URL = "http://Marsh.ath.cx:88/ticket/android.php"
Dim HttpClient1 As HttpClient
Dim Fone As Long
Dim Pin As Long
Dim Confirm As Long

Fone = 0
Pin = 0
Confirm = 0
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim Label1 As Label
Dim Button1 As Button
Dim EditText1 As EditText ' phone
Dim EditText2 As EditText ' confirmation code
Dim EditText3 As EditText ' pin code
Dim ticketinfo As String
Dim ImageView1 As ImageView
Dim Label2 As Label
Dim Label3 As Label
Dim Label4 As Label
Dim Label5 As Label
Dim Label6 As Label
Dim Label7 As Label
Dim Label8 As Label
Dim Label9 As Label
Dim ImageView2 As ImageView
Dim ImageView3 As ImageView
Dim ImageView4 As ImageView
' Dim WebView1 As WebView
' Dim WebView2 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hc.Initialize("hc")
End If

Activity.LoadLayout("Main")
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

Dim btn As Button
btn = Sender 'Fetch the actual button that raised this event.
CurrentTask = btn.Tag 'Take the object from its Tag property.

Dim request As HttpRequest
Text = "Please enter phone number: "
EditText1.InputType = EditText1.INPUT_TYPE_NUMBERS
Fone = EditText1.Text

Text = "Please enter confirmation number: "
EditText2.InputType = EditText2.INPUT_TYPE_NUMBERS
Confirm = EditText2.Text

Text = "Please enter Pin Code: "
EditText3.InputType = EditText3.INPUT_TYPE_NUMBERS
Pin = EditText3.Text

request.InitializeGet(URL & "?Fone=" & Fone & "&confirm=" & Confirm & "&pincode=" & Pin & "&edit=Register")

If hc.Execute(request, 1) = False Then Return 'Will be false if their is already a running task (with the same id).
Return
End Sub

Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Log("ResponseSuccess")
ProgressDialogHide
Dim result As String
result = Response.GetString ("UTF8") ' Convert the response to a string
Log(result)
Process_info (result)
End Sub

Sub Process_info (info As String)
' Parsing
Dim rtexttholder As String

Dim rtextskunum As String
Dim rtextdatetime As String
Dim rtextpurchaser As String
Dim rtextcompany As String
Dim rtextskuimage As Object
Dim rtextcompanyimg As Object
Dim rtextpurchaserimg As Object

Dim rtext As String
Dim dataholder As Map
Dim mapobj As Map
Dim sitems As List
Dim JSON As JSONParser
Dim i As Int

JSON.Initialize(info)
sitems = JSON.NextArray
For i = 0 To sitems.Size - 1
dataholder = sitems.Get(i)
rtext = rtext & "Ticket PO: " & dataholder.Get("firstname") & " " & dataholder.Get("lastname") & CRLF & "Purchase: " & dataholder.Get("purchaser") & " Company: " & dataholder.Get("company")& " Date/Time: " & dataholder.Get("datetime") & CRLF & "Sku: " & dataholder.Get("sku")

rtexttholder = "Ticket PO: " & dataholder.Get("firstname") & " " & dataholder.Get("lastname")
rtextskunum = "Sku: " & dataholder.Get("sku")
rtextdatetime = "Date/Time: " & dataholder.Get("datetime") & " Anywhere USA "
rtextpur = "Purchaser: " & dataholder.Get("purchase")
rtextcom = "Company: " & dataholder.Get("company")

rtextcompanyimg = dataholder.Get("companyimg")
rtextpurchaseimg = dataholder.Get("purchasecompanyimg")

Next

Activity.LoadLayout("activitylogo")

If rtext = "" Then



Label1.Text = " All Information Retrieved for Confirmation Code" & Confirm & "Thank You"
Return
Else
' ImageView1.Initialize("")
' Activity.AddView(ImageView1, 0, 0, 320, 480) ' ActivityLogo (second one).AddView(ImageView1 As android.view.View, Left As Int, Top As Int, Height As Int)

ImageView2.Initialize("rtextcompanyimg")
ImageView3.Initialize("rtextpurchaserimg")
ImageView4.Initialize("")

Activity.AddView(ImageView1, 0, 40, 80, 80)
Activity.AddView(ImageView2, 400, 40, 80, 80)
Activity.AddView(ImageView4, 160, 130, 190, 40)

Label1.Text = rtexttholder
Label5.Text = rtextskunum
' Label6.Text = rtextskuimage
Label7.Text = rtextdatetime
Label8.Text = rtextcom
Label9.Text = rtextpur

End If


Return
End Sub
Sub hc_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
' was HttpClient1
Log(Reason)
Log(StatusCode)
ProgressDialogHide
msg = "Error connecting to server."
If Reason <> Null Then msg = msg & CRLF & Reason
ToastMessageShow (msg, True)
End Sub
 
Top