I am trying to apply the code below, but it seems like the event is not rising so no message is shown at incoming call. I am using Samsun Galaxy S5, it is using Kitkat.
If can help, is there any thread shows what functions and features discontinued in Kitkat in general ?!
B4X:
Sub Process_Globals
Dim PE As PhoneEvents
End Sub
Sub Service_Create
PE.Initialize("PE")
End Sub
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
Msgbox(State,"Test")
End Sub
No, this service module is called at Activity_Create in the Main module of the application
Below is the code in the Main module, where the services module is named "SPhone"
B4X:
Sub Globals
Private ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
If FirstTime Then StartService(SPhone)
End Sub
I'm not completely sure, but I think that you cannot have a ToastMessage (or a MsgBox) in a Service. The service is 'invisible' by concept.
Try to add Log(State & "- " ...) and see the log
If you want toasmessages, you should CallSub a sub in your activity, which can perform a ToastMessage (if the Activity is in Foreground, of course)
Code written in an activity module is paused once the activity is not visible.
So by only using activities it is not possible to run any code while your application is not visible.
Services life cycle is (almost) not affected by the current visible activity. This allows you to run tasks in the background.
Services usually use the status bar notifications to interact with the user. Services do not have any other visible elements. Services also cannot show any dialog (except of toast messages).