Android Question Error Messages from Playstore

kohle

Active Member
Licensed User
Longtime User
For about 3 weeks, I have a new version of my app in the play store, compiled with
b4a 7.01. I get 2 errors from the app store.
It seems to happen on some celphones, not all.


18.06.17 Moto G, 1GB, Android 6.0
java.lang.RuntimeException:
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap17(ActivityThread.java:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1452)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.RuntimeException:
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at jk.rt_calendar.pushservice.handleStart(pushservice.java:105)
at jk.rt_calendar.pushservice.access$000(pushservice.java:8)
at jk.rt_calendar.pushservice$1.run(pushservice.java:70)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:105)
at jk.rt_calendar.pushservice.onStartCommand(pushservice.java:68)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3028)


25.06.17 Samsung Galaxy A5, Android 5, 2GB Memory

java.lang.OutOfMemoryError: OutOfMemoryError thrown while
trying to throw OutOfMemoryError; no stack available

How it reported it should happen here, when I click on a listitem
and make the listitem "bigger" and show some invisible imageviews.


B4X:
Sub expandListItem (Index As Int,Value As Long)
    Dim pnl As Panel
    Dim en As CalEntry
    Dim hei As Long
    Dim col As Int
    Dim i As Int
   
    Dim  bu3 As ImageView
   
    pnl = CLV1.GetPanel(Index)

   
    If gl_indexOld<> -1 Then
        shrinkListItem (gl_indexOld )
    End If
    gl_indexOld = Index
    Dim en As CalEntry
    Value = CLV1.GetValue(Index)
    en.Initialize
    en = CalEntries.Get(Value-1)
    hei = ItemHeight
    pnl=CreateListItem2(en.Title ,en.Description,en.Description2, pScreenWidth, hei,en)

    bu3=pnl.GetView(3) 'more
    bu3.Visible=False

   
    For i=4 To 8
        Dim  bu As ImageView
        bu=pnl.GetView(i)
        bu.Visible=True
    Next
    CLV1.ReplaceAt(Index,pnl,hei,Value)
    col = en.pbackcolor
    pnl.Color=col
   


       
   

   


   
   
   
   
End Sub
 

kohle

Active Member
Licensed User
Longtime User
OOM error :

I dont load large image, but I think too many.
I have a customlist with about 20 listview items. When I click on an item i expand the height and show some icons (png),
like "send Email", " Location",...
I think the problem is that I add at the beginning to every listview item and later I show with visible = true
I tested with about 7 phones but I will try to create the icons only for the listview-item I expand and destroy it again.
What you think ?


Second problem :

There about 150 cellphones rumning with the app where the push-service works. Strange.
Here the Code :


B4X:
#Region Module Attributes
    #StartAtBoot: False
#End Region

'Service module
'Version 0.9
Sub Process_Globals
Dim sNotif As Notification
End Sub
Sub Service_Create
   
End Sub

Sub Service_Start (StartingIntent As Intent)
    Select StartingIntent.Action
        Case "com.google.android.c2dm.intent.REGISTRATION"
            HandleRegistrationResult(StartingIntent)
        Case "com.google.android.c2dm.intent.RECEIVE"
            MessageArrived(StartingIntent)
    End Select
End Sub
Sub MessageArrived (Intent As Intent)
    Dim From, CollapseKey, Data As String 'ignore
    If Intent.HasExtra("from") Then From = Intent.GetExtra("from")
    If Intent.HasExtra("data") Then Data = Intent.GetExtra("data")
    If Intent.HasExtra("collapse_key") Then CollapseKey = Intent.GetExtra("collapse_key")

Log(Data)
    'Here you should handle the new message:
    Log("New message arrived: " & Data)
    ToastMessageShow("New message: " & Data, True)
   
    sNotif.Initialize
    sNotif.AutoCancel=True
    sNotif.Icon = "icon"
    sNotif.SetInfo("Calendário RT" , Data,Main)
    sNotif.Sound = False
    sNotif.AutoCancel=True
    sNotif.Notify(1)

   
   
End Sub


Sub RegisterDevice (Unregister As Boolean)
   

   
   
    Dim i As Intent
    If Unregister Then       
        i.Initialize("com.google.android.c2dm.intent.UNREGISTER", "")
    Else
        i.Initialize("com.google.android.c2dm.intent.REGISTER", "")
        i.PutExtra("sender", Main.SenderId)
    End If
    Dim r As Reflector
    Dim i2 As Intent
    i2 = r.CreateObject("android.content.Intent")
    Dim pi As Object
    pi = r.RunStaticMethod("android.app.PendingIntent", "getBroadcast", _
        Array As Object(r.GetContext, 0, i2, 0), _
        Array As String("android.content.Context", "java.lang.int", "android.content.Intent", "java.lang.int"))
    i.PutExtra("app", pi)
    StartService(i)
End Sub

Sub HandleRegistrationResult(Intent As Intent)
   
    Dim rid As String
    rid = Intent.GetExtra("registration_id")


    If Intent.HasExtra("error") Then
        Log("Error: " & Intent.GetExtra("error"))
        ToastMessageShow("Error: " & Intent.GetExtra("error"), True)
    Else If Intent.HasExtra("unregistered") Then
        Dim j As HttpJob
       
        j.Initialize("UnregisterTask", Me)
       
        j.Download2(Main.BoardUrl, Array As String("device_password", Main.DeviceBoardPassword _
            ,"name", "DEL", "id", rid)) 'Empty id is sent here. This will cause the board to delete this name.
    Else If Intent.HasExtra("registration_id") Then
       
        Log(rid)
       
        Dim j As HttpJob
        j.Initialize("RegisterTask", Me)
        j.Download2(Main.BoardUrl, Array As String("device_password", Main.DeviceBoardPassword, _
            "name", Main.DeviceName, "id", rid))
    End If
End Sub
Sub JobDone(Job As HttpJob)
    If Job.Success Then
        Select Job.JobName
            Case "RegisterTask"
                'ToastMessageShow("Registration completed successfully.", False)
            Case "UnregisterTask"
                ToastMessageShow("Unregistration completed successfully.", False)
        End Select
    Else
        ToastMessageShow("Error sending request.", True)
        Log(Job.ErrorMessage)
    End If
    Job.Release
End Sub

Sub Service_Destroy

End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I think the problem is that I add at the beginning to every listview item and later I show with visible = true
Make sure not to load the same bitmap multiple times. Load it once and reuse it.

There about 150 cellphones rumning with the app where the push-service works.
Do you mean that it doesn't work? In the long run I recommend you to switch to Firebase. It is simpler and more reliable.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Samsung phones "always" have memory issues... but that's not to say that it's all their fault.

As Erel mentions you need to reuse the bitmaps - not keep on loading them again and again. Define it in globals and the problem should disappear...

Maybe post some of the code in question..? Oops - just saw your code!

Where is the bitmap defined or loaded, I can't seem to see this part of the App..

B4X:
      TempPNG = LoadBitmapSample(File.DirAssets, Cursor2.GetInt("series_no") & "_logo.png",128,128)



      ListView2.AddTwoLinesAndBitmap(Cursor2.GetString("series"), "", TempPNG)

with TempPNG defined in Globals..
 
Upvote 0
Top