Greetings,
I using PhoneStateChanged of PhoneEvents from the Phone library for the first time for a new user requirement. To better understand how it works I found a few references to code samples in the forum. Based on those samples, I made this simple app. I added the coding to the Starter service. Maybe that's where I went wrong. I rang my mobile to see if it work but the logs don't show that the phone state sub is responding. There are no error messages in the Logs and they show the Starter service is running. Can you let me know if I can do this in the Starter service and what coding changes I need to make? It's a super simple app but I know I'm missing something. Maybe in the manifest editor?
I using PhoneStateChanged of PhoneEvents from the Phone library for the first time for a new user requirement. To better understand how it works I found a few references to code samples in the forum. Based on those samples, I made this simple app. I added the coding to the Starter service. Maybe that's where I went wrong. I rang my mobile to see if it work but the logs don't show that the phone state sub is responding. There are no error messages in the Logs and they show the Starter service is running. Can you let me know if I can do this in the Starter service and what coding changes I need to make? It's a super simple app but I know I'm missing something. Maybe in the manifest editor?
Main Module:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Starter Service Module:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Dim PhoneId As PhoneId
Dim PE As PhoneEvents
End Sub
Sub Service_Create
PE.InitializeWithPhoneState("PE", PhoneId)
Log("Starter service created.")
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End Sub
Sub Service_TaskRemoved
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
Log("This phone is " & State & ".")
End Sub