Android Question B4A, Service Problems a boot, at restart service application.

delgadol

Member
I have an application that is type soft phone; it has 3 simple activities:

1. Registration of credentials
2. Dialpad
3. Calls;
4. Phone service that starts at boot
5. start that starts phone when user applies task killer

everything works fine until the user comes up with the genius of applying the task killer;

my happens the following:

Andorid 4.4-7.1.1 -
All function OK, the softphone service returns without any problem.

Android 8,9,10, the softphone service returns, but my activities are totally null.

java.lang.NullPointerException: Attempt to read from field 'net.dumaco.voipapp2.call net.dumaco.voipapp2.tservvoipphone._call' on a null object reference

???

look to initialize the activities as Intent, but when trying to see their status, with the ISPaused function; he goes crazy and hangs.

Everything runs normal in real cell phones with android less than or equal to 7.1.1 but when going up to 8 my problems begin; and if they are xiaomi or huawei worse.

could you give me a hand?
 

Attachments

  • TServVoipPhone.bas
    12.3 KB · Views: 87

JohnC

Expert
Licensed User
Longtime User
Are you using the StartServiceAt function to specify a time a few minutes in the future to auto-restart your service in case it was killed by a task killer?
 
Last edited:
Upvote 0

delgadol

Member
The arquitecture form is a follow (simple phone interfaces) :

1. Main Activity
2. DialPad Activity
3. Call Activity
4. Start Service (by default)
5. TSerVoipPhone (Listed a Android Service From ABto Trial SDK)


Start Service listen when the user remove app from list app o use the task killer (it works in almost android test)


Listen a User kill app and use the task killer:
Sub Service_Destroy
    Log("Service is Destory")
    CancelScheduledService(TServVoipPhone)
    StopService(TServVoipPhone)
End Sub

Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
    Log("Service task remove")
    CancelScheduledService(TServVoipPhone)
    StopService(TServVoipPhone)
    'StartServiceAt(TServVoipPhone,5000,False)
End Sub

on TSerVoipPhone catch "kill by user" an try to restore

Listen a User kill app and use the task killer:
Sub Service_Destroy
    Log("Voip is Destory")
    StartServiceAt(Me,5000,False)
End Sub

Sub Service_TaskRemoved
    Log("Voip is task removed")
    StartServiceAt(Me,5000,False)
End Sub


The service run again (have all permision, autostar,battery optimization)

whats is the problem ?

Service task remove <- service remove by the user
** Service (tservvoipphone) Destroy ** <- stop service from start
Voip is Destory <- service destroy listen
onRemoteAlerting = [Ljava.lang.Object;@2f51101 <- service is Up Again
OnIncomingCall = [Ljava.lang.Object;@20bc3d <- service report a incoming call

Call Activity IncommingcALL:
Sub Voip_OnIncomingCall(uri As String, callId As Long)

    Log($"Voip_OnIncomingCall(${uri}, ${callId})"$)
    VoipCallInfo.ContacName = uri
    VoipCallInfo.IsVideo = VoipPhone.isVideoCall
    'VoipCallInfo.State = PhoneState.call_state_iscomming
    VoipCallInfo.State = 2
    SetAndNotify(DevNotHandlerMsg.voip_OnInCall.Replace(":%1",uri),Call) <- Error [ line: 424] ' I try comment this line but error success after
    StartActivity(Call) <- Error

End Sub

Voip_OnIncomingCall(<sip:delgadol@iptel.org>, 1) <- service listen handler a incoming call
isVideoCall allowed = true <- Video permitted
check for video call
at this time
tservvoipphone_voip_onincomingcall (java line: 424)
java.lang.NullPointerException: Attempt to read from field 'net.dumaco.voipapp2.devnothandlermsg net.dumaco.voipapp2.tservvoipphone._devnothandlermsg' on a null object reference
at net.dumaco.voipapp2.tservvoipphone._voip_onincomingcall(tservvoipphone.java:424)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at org.abtollc.sdk.b4a.AbtoPhone.raiseEvent(AbtoPhone.java:844)
at org.abtollc.sdk.b4a.AbtoPhone.OnIncomingCall(AbtoPhone.java:765)
at org.abtollc.sdk.AbtoPhone$8.handleMessage(AbtoPhone.java:469)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:221)
at android.app.ActivityThread.main(ActivityThread.java:7520)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)


This Error is on android 9/10 and MIU 8.1 , on emulator run OK.

thanks in advence.
 
Upvote 0

delgadol

Member
Are you using the StartServiceAt function to specify a time a few minutes in the future to auto-restart your service in case it was killed by a task killer?

yes, if the user kill the app by "remove app list" or use "task killer"; y use StartServiceAt(Me,Time,False); and work; in any android version; but when i try to start any activity or call any code module , all are null.
 
Upvote 0

delgadol

Member
Looks like the error is here: SetAndNotify(DevNotHandlerMsg.voip_OnInCall.Replace(":%1",uri),Call) <- Error [ line: 424] ' I try comment this line but error success after

What is DevNotHandlerMsg? Where is it initialized?

it is code module " DevNotHandlerMsg " , public const string voip_OnInCall ;

I comment this line

SetAndNotify(DevNotHandlerMsg.voip_OnInCall.Replace(":%1",uri),Call) <- Error [ line: 424] ' I try comment this line but error success after

and this error show :


StartActivity(Call) <- Error

java.lang.NullPointerException: Attempt to read from field 'net.dumaco.voipapp2.call net.dumaco.voipapp2.tservvoipphone._call' on a null object reference

why after the taks killer kill the app; all activities, code module are a null ?, although the service is active again.
 
Upvote 0
Top