Android Question Run Application on Debug and Release

Imad71

Member
Hello,
Based on following :-
private Sub ReadData
Private My_Query As JdbcResultSet = MYSQL.ExecQuery("SELECT CityID FROM tblCity")
RowIDList.Clear
Do While My_Query.NextRow
RowIDList.Add(My_Query.GetInt2(0))
Loop
CurrentIndex = 0
My_Query.Close
End Sub

private Sub Show_Data(EntryIndex As Int)
Private MY_Query As JdbcResultSet
B4XTable1.AddColumn("City ID" , B4XTable1.COLUMN_TYPE_NUMBERS)
B4XTable1.AddColumn("City Name" , B4XTable1.COLUMN_TYPE_TEXT)

Dim Data As List
Data.Initialize
MY_Query = MYSQL.ExecQuery("SELECT * FROM tblCity")
Do While MY_Query.NextRow
Dim Rows(2) As Object
Rows(0) = MY_Query.GetInt2(0)
Rows(1) = MY_Query.GetString2(1)
Data.Add(Rows)
Loop
MY_Query.Close
B4XTable1.SetData(Data)
End Sub

private Sub B4XPage_Appear
conLinkServer
RowIDList.Initialize
End Sub

Private Sub brnLoadData_Click
ReadData
Show_Data(0)
End Sub


First when B4XPage Appear get Link to SQL Server,
Second when press Button need to read and Show Data on B4XTable,

that process work fine when run in Debug Mode, But when run in Release mode, I got Error on Reading Data as following:
"android.os.NetworkOnMainThreadException"

What Exactly the case to be take care between Debug and Release ?

many thanks in advance
 

Peter Simpson

Expert
Licensed User
Longtime User
Upvote 0

Imad71

Member
Thanks Peter Simpson , it has solved that issue,
but some thing happen here,
when go to pageNo2 at first time everything work fine,
if leave the PageNo2 and back to it again, got error as following:

java.lang.RuntimeException: Class instance was not initialized (b4xtable)




i have reload the code as advised by erel


java.lang.RuntimeException: Class instance was not initialized (b4xtable):
private Sub ReadData
    
Try
    Private My_Query As JdbcResultSet = MYSQL.ExecQuery("SELECT CityID FROM tblCity")
    RowIDList.Clear
    Do While My_Query.NextRow
        RowIDList.Add(My_Query.GetInt2(0))
    Loop
    CurrentIndex = 0
        My_Query.Close
    Catch
        Log(LastException.Message)
        ToastMessageShow(LastException.Message,True)
    End Try
End Sub

private Sub Show_Data(EntryIndex As Int)
    Try
    Private MY_Query As JdbcResultSet
    B4XTable1.Clear
    B4XTable1.AddColumn("City ID" , B4XTable1.COLUMN_TYPE_NUMBERS)
    B4XTable1.AddColumn("City Name" , B4XTable1.COLUMN_TYPE_TEXT)
    
    Dim Data As List
    Data.Initialize
    MY_Query =  MYSQL.ExecQuery("SELECT * FROM  tblCity")
    Do While MY_Query.NextRow
    Dim Rows(2) As Object
        Rows(0) = MY_Query.GetInt2(0)
        Rows(1) = MY_Query.GetString2(1)
        Data.Add(Rows)
    Loop
    MY_Query.Close
    B4XTable1.SetData(Data)
    
    Catch
        Log(LastException.Message)
        ToastMessageShow(LastException.Message,True)
    End Try
End Sub

Private Sub brnLoadData_Click
    conLinkServer
    Sleep(10)
    RowIDList.Initialize
    ReadData
    Show_Data(0)
End Sub
 
Upvote 0
Top