Android Question Freeze after StartActivity with locked screen

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
My app wakes the screen when receiving specific message via websocket. The communication is handled with a separate service.
I check if the activity I want to run is paused and I start it when the app receives the message.
If the screen is locked during StartActivity, the result is a black screen, some seconds delay and finally the system dialog for ANR.
If I press Close, the app restarts automatically.
What could I do to prevent the app freeze?

Thank you in advance.
 

vfafou

Well-Known Member
Licensed User
Longtime User
Hello DonManfred and lemonisdead!
Thank you for your responses!
I'll post the code later in the day because I'm at work now... so you can see what happens!
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
This is a crash log I succeeded to take!
B4X:
~i:Class not found: anywheresoftware.b4a.samples.customlistview.customlistview, trying: com.vf.rmmobi.customlistview
~i:Panel size is unknown. Layout may not be loaded correctly.
~i:** Activity (actworker) Resume **
WakeLock already held.
Partial wakeLock already held.
OK
~i:** Service (gpsservice) Start **
~i:** Service (pushservice) Start **
~e:actworker_updatestatus (java line: 14035)
~e:java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Exception anywheresoftware.b4a.BA.getLastException()' on a null object reference
~e:    at anywheresoftware.b4a.keywords.Common.LastException(Common.java:803)
~e:    at com.vf.rmmobi.actworker._updatestatus(actworker.java:14035)
~e:    at java.lang.reflect.Method.invoke(Native Method)
~e:    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
~e:    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1044)
~e:    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:986)
~e:    at com.vf.rmmobi.pushservice._service_start(pushservice.java:435)
~e:    at java.lang.reflect.Method.invoke(Native Method)
~e:    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
~e:    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
~e:    at com.vf.rmmobi.pushservice.handleStart(pushservice.java:105)
~e:    at com.vf.rmmobi.pushservice.access$000(pushservice.java:8)
~e:    at com.vf.rmmobi.pushservice$1.run(pushservice.java:70)
~e:    at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:105)
~e:    at com.vf.rmmobi.pushservice.onStartCommand(pushservice.java:68)
~e:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3476)
~e:    at android.app.ActivityThread.-wrap23(ActivityThread.java)
~e:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1674)
~e:    at android.os.Handler.dispatchMessage(Handler.java:105)
~e:    at android.os.Looper.loop(Looper.java:156)
~e:    at android.app.ActivityThread.main(ActivityThread.java:6523)
~e:    at java.lang.reflect.Method.invoke(Native Method)
~e:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
~e:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Exception anywheresoftware.b4a.BA.getLastException()' on a null object reference
at anywheresoftware.b4a.keywords.Common.LastException(Common.java:803)
at com.vf.rmmobi.actworker._updatestatus(actworker.java:14035)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1044)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:986)
at com.vf.rmmobi.pushservice._service_start(pushservice.java:435)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at com.vf.rmmobi.pushservice.handleStart(pushservice.java:105)
at com.vf.rmmobi.pushservice.access$000(pushservice.java:8)
at com.vf.rmmobi.pushservice$1.run(pushservice.java:70)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:105)
at com.vf.rmmobi.pushservice.onStartCommand(pushservice.java:68)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3476)
at android.app.ActivityThread.-wrap23(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1674)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Hello Erel!
Thank you... You know!
Here it is:
B4X:
Sub UpdateStatus(sMap As Map)
    Private status As Boolean
    Private info   As Boolean
    Private sound  As Boolean
 
    status = sMap.Get("sts")
    info   = sMap.Get("prev")
    sound  = sMap.Get("sound")
 
    Try
        If status Then
            setIDColor(status)
            If info Then
                If Starter.onClaim = 0 And sound Then
                    PlayMedia("restcomm.ogg")
                End If
             
                If sound Then
                    ToastMessageShow("Connection Established!",True)
                    'GetResumeInfo
                End If
                 
            End If
        Else
            setIDColor(status)
            StopClaim(0)
         
            If Starter.onClaim = 0 Then
                PlayMedia("lostcomm.ogg")
            End If
         
        End If
    Catch
        Log("Error lblID: " & LastException)
    End Try
End Sub
And:
B4X:
Sub setIDColor(pStatus As Boolean)
    Private idc As ColorDrawable
    Private clr As Int
  
    If pStatus Then
        clr = Colors.RGB(0,130,95)
    Else
        clr = Colors.RGB(190,0,60)
    End If
  
    idc.Initialize2(clr,2dip,1dip,Colors.RGB(90,95,110))
  
    lblId.Background = idc
  
End Sub
And this is called like:
B4X:
If IsPaused(ActWorker) = False Then
        Private stMap As Map
        stMap.Initialize
        stMap.Put("sts",wsh.ws.Connected)
        stMap.Put("prev",prevConn)
        stMap.Put("sound",True)
        CallSub2(ActWorker, "UpdateStatus", stMap)
    End If
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Hi Erel!
I'll try without try/catch...
The activity is not visible... It seems that the error occurs when it is going to be resumed. The case is that this happens only when it tries to wake from a password locked screen.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…