Android Question Anyone has experienced in Android 10, whny activity close and open repeatedly when we click to another activity.

nickysuwandi

Member
Licensed User
Anyone has experienced in Android 10, activity close and open repeatedly when we click to another activity.

When 1 clicked detail product activity (call product activity), th apps open the activity andclose it (repeatedly).
Sometimes it will take 5 time repeat open and close.
Anyone know where wrong, i had use this program about 6 month, only today 1 have problem when some android phone update.

Thanks

Nicky
Logger connected to: OPPO CPH1821
--------- beginning of crash
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (mainmenu) Create, isFirst = true **
** Activity (mainmenu) Resume **
--------- beginning of system
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (trxdetail) Create, isFirst = true **
** Activity (trxdetail) Resume **
** Activity (trxdetail) Pause, UserClosed = true **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (trxdetail) Create, isFirst = false **
** Activity (trxdetail) Resume **
** Activity (trxdetail) Pause, UserClosed = false **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **

in here , cousing activity open (trxdetail) and open (mainmenu), repeatedly

sending message to waiting queue (CallSubDelayed - JobDone)
** Activity (trxdetail) Resume **
** Activity (trxdetail) Pause, UserClosed = true **
running waiting messages (1)
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (trxdetail) Create, isFirst = false **
** Activity (trxdetail) Resume **
** Activity (trxdetail) Pause, UserClosed = false **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (trxdetail) Resume **
** Activity (trxdetail) Pause, UserClosed = false **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (trxdetail) Resume **
** Activity (trxdetail) Pause, UserClosed = false **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (trxdetail) Resume **
** Activity (trxdetail) Pause, UserClosed = false **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (trxdetail) Resume **
** Activity (trxdetail) Pause, UserClosed = false **
** Activity (mainmenu) Resume **
 

DonManfred

Expert
Licensed User
Where is the relevant code?
Have you running httpjobs in your main activity which maybe ends? Move the communication to a service.

Switch to B4XPages and forget about such issues.
 
Last edited:
Upvote 0

jahswant

Well-Known Member
Licensed User
Use B4XPages and you’ll not see theses issues. This is because of the JobDone Sub being called when activity is not active I guessed.
 
Upvote 0

nickysuwandi

Member
Licensed User
Where is the relevant code?
Have you running httpjobs in your main activity which maybe ends? Move the communication to a service.

Switch to B4XPages and forget about such issues.


This the code Don Manfred, when i click item produk (in activity Main Menu), it will go to display item detail (activity trxdetail).
the problem is when i click item produk, the app will open screen trx detail then back to mainmenu (repeatedly about 5-10 times, until the app stop and display the trxdetail screen).

Thanks

In activity MainMenu (when click )

List View item Clicked:
Sub lv_page0_ItemClick (Position As Int, Value As Object)
    Dim splt() As String  = Regex.Split("\|",Value)
    StartActivity(trxdetail)
    trxdetail.strproduk =splt(0)
    trxdetail.strdec=splt(1)
    trxdetail.intmodal=splt(2)
    trxdetail.intjlh=splt(3)
    trxdetail.intharga=splt(4)
    trxdetail.intoldjlh=0
    wait for (CekCart(splt(0))) complete (rslt As Boolean)
End Sub


in activity trxdetail (this display item detail)

activity trxdetail:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    If FirstTime Then
        SQL1.Initialize(File.DirInternal, "db.db", True)
    End If
    listharga.Initialize
    Activity.LoadLayout("Laytrxdetail")
    lblDesc.Text =strdec
    lblKode.Text =strproduk
    lbljumlah.Text ="Jumlah (stok : " & NumberFormat(intjlh,0,0) & ")"
    etHarga.Text=NumberFormat(intharga,0,0)
    etJumlah.Text=1
    If intoldjlh > 0 Then
        etJumlah.Text=intoldjlh
    End If
End Sub

Sub Activity_Resume
    If Starter.BooKillActivity=True Then
        Activity.Finish
    End If
    listharga.Clear
    wait for (PHarga) complete (rslt As Boolean)
    
    Try
        If listharga.Size<=0 Then
            ToastMessageShow("Gagal Loading Harga, Silahkan Ulangin",True)
            Activity.Finish
        Else
            'cek jika jumlah baris berbeda dgn jumlah baris dalam harg maka ulangin lagi
            Dim Mapx As Map,Booloadinglagi As Boolean,intbaris,intbarisl As Int
            Booloadinglagi=False
            intbaris=0
            intbarisl=listharga.Size
            For i=0 To listharga.Size-1
                Mapx = listharga.Get(i)
                If IsNumber(Mapx.Get("baris")) Then
                    intbaris=Mapx.Get("baris")
                    If intbaris <> intbarisl Then
                        Booloadinglagi=True
                    End If
                Else
                    Booloadinglagi=True
                End If
                Exit
            Next
            If Booloadinglagi=True Then
                ToastMessageShow("Gagal Loading Harga, Silahkan Ulangin",True)
                Activity.Finish
            End If
        End If
    Catch
        ToastMessageShow("Gagal Loading Harga, Silahkan Ulangin",True)
        Activity.Finish
    End Try
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    UserClosed=True
End Sub


Sub btnBeli_Click
    PTambahData
    Starter.intjlhcart=Starter.intjlhcart+1
    Activity.Finish
End Sub

Sub btnBatal_Click
    Activity.Finish
End Sub

Sub btnMinus_Click
    If etJumlah.Text>0 Then
        etJumlah.Text=NumberFormat(etJumlah.Text-1,0,0)
    '    PValidasiHarga
    End If
    
End Sub

Sub btnPlus_Click
'    If etJumlah.Text < intjlh Then
        etJumlah.Text=NumberFormat(etJumlah.Text+1,0,0)
       ' PValidasiHarga
'    End If
End Sub

Sub etJumlah_TextChanged (Old As String, New As String)
    PValidasiHarga
End Sub

Sub PTambahData
    Dim strsql As String ,inttotal As Long
    strsql="select count(*) from trdinvfa where kode='" & lblKode.Text  & "' and modal=" & intmodal
    If SQL1.ExecQuerySingleResult(strsql)>0 Then
        'strsql="update trdinvfa set jumlah=jumlah+" & etJumlah.Text & ",jumlah_max=" & intjlh & " where kode='" & lblKode.Text  & "' and modal=" & intmodal
        strsql="delete from trdinvfa where kode='" & lblKode.Text  & "' and modal=" & intmodal
        SQL1.ExecNonQuery(strsql)
    End If
    strsql="insert into trdinvfa (kode,desc,modal,harga,jumlah,jumlah_max) values('" & lblKode.Text  & "','" & lblDesc.Text & "'," & intmodal & "," & etHarga.Text.Replace(",","")  & "," & etJumlah.Text.Replace(",","") & "," & intjlh & ")"
    SQL1.ExecNonQuery(strsql)
    Dim intharga,intjlh As Int
    intharga=etHarga.Text.Replace(",","")
    intjlh=etJumlah.Text.Replace(",","")
    
    'update total
    inttotal=SQL1.ExecQuerySingleResult("SELECT printf('%f',sum(jumlah*harga)) from trdinvfa ")
    
    strsql="select count(*) from trhinvfa"
    If SQL1.ExecQuerySingleResult(strsql)>0 Then
        strsql="update trhinvfa set total=" & inttotal
    Else
        strsql="insert into trhinvfa (total) values(" & inttotal & ")"
    End If
    SQL1.ExecNonQuery(strsql)
End Sub

Sub PValidasiHarga
    Dim intj1,intj2,intjr,inthrg As Int
    intjr=0
    If IsNumber(etJumlah.Text.Replace(",","")) Then
        intjr=etJumlah.Text.Replace(",","")
    End If
    
    If listharga.Size>0 And intjr>0 Then
        Dim Mapx As Map
        For i=0 To listharga.Size-1
            Mapx = listharga.Get(i)
            intj1=0
            intj2=0
            inthrg=0
        
            If Mapx.Get("produk")<>strproduk Then
                listharga.Clear
                ToastMessageShow("Gagal Loading Harga, Silahkan Ulangin",True)
                Activity.Finish
            End If
            If IsNumber(Mapx.Get("jumlah1")) Then
                intj1=Mapx.Get("jumlah1")
            End If
            If IsNumber(Mapx.Get("jumlah2")) Then
                intj2=Mapx.Get("jumlah2")
            End If
            If IsNumber(Mapx.Get("harga")) Then
                inthrg=Mapx.Get("harga")
            End If
            If intjr>=intj1 Then
                If intjr<=intj2 Then
                    If inthrg>0 Then
                        etHarga.Text=NumberFormat(inthrg,0,0)
                        Exit
                    End If
                End If
            End If
        Next
    End If
End Sub

Sub PHarga As ResumableSub
    Dim j As HttpJob
    j.Initialize("harga" , Me)
    'Request data user ke server.
    Dim S As String = Starter.serverAddress & "/getmaster.php"
    listharga.Clear
    j.Download2(s, Array As String("jns", "harga","jns1", strproduk,"jns2","","usr", Starter.strusr, "psw",Starter.strtoken))
    wait for (j) JobDone(job As HttpJob)
    
    If job.Success = False Then
        ToastMessageShow("Tidak ada jaringan, Silahkan ulangin lagi", True)
        ProgressDialogHide
    Else
        Dim Map1 As Map
        Dim JSON As JSONParser
        Map1.Initialize
        Try
            JSON.Initialize(job.GetString)
            Dim list1 As List
            list1= JSON.Nextarray
            Map1 = list1.Get(0)
            Dim hs As String = Map1.Get("hasil")
            If(hs = "TRUE") Then
                listharga= Map1.Get("nama")
            End If
        Catch
            Log(LastException)
        End Try
        ProgressDialogHide
    End If
    job.Release
    Return job.Success
End Sub
 
Upvote 0

nickysuwandi

Member
Licensed User
the code of CeKCart is missing.

This the CekCart, not missing (forget to copy it)

CekCart:
Sub CekCart(strpro As String) As ResumableSub
    Try
        Dim strsql As String
        strsql="select harga,jumlah,modal from trdinvfa where kode='" & strpro & "' limit 1"
        Dim Curs As Cursor
        Dim i As Int
        Curs = SQL1.ExecQuery(strsql)
        Curs.Position = 0
        For i = 0 To Curs.RowCount - 1
            Curs.Position = i
            trxdetail.intmodal=Curs.GetInt("modal")
            trxdetail.intjlh=Curs.GetInt("jumlah")
            trxdetail.intharga=Curs.GetInt("harga")
            trxdetail.intoldjlh=Curs.GetInt("jumlah")
        Next
        Curs.Close
    Catch
        Log(LastException)
    End Try
End Sub
 
Upvote 0
Top