Hi,
I try to build my first app based on a service. The service is starting well, also on boot.
The service will make a notification. From the notification I want be back to my form of the process. This happens, but the form is empty. The form only contains a button and a edittext.
Here is the source of the process:
Here is the source of the service:
It is a short code only for testing.
Do I have to reload the layout and how?
Best regards,
André
I try to build my first app based on a service. The service is starting well, also on boot.
The service will make a notification. From the notification I want be back to my form of the process. This happens, but the form is empty. The form only contains a button and a edittext.
Here is the source of the process:
B4X:
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.
Dim EditText1 As EditText
Dim Button1 As Button
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")
If(FirstTime=True) Then
StartService(CIRISChecker)
Activity.LoadLayout("Main")
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Here is the source of the service:
B4X:
#Region Service Attributes
#StartAtBoot: True
#StartCommandReturnValue: android.app.Service.START_STICKY
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim n As Notification
Dim Aan As Boolean
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
End Sub
Sub Service_Start (StartingIntent As Intent)
'schedule the service to start every 2 minutes. Note that StartAtBoot is set to trye
StartServiceAt(Me, DateTime.Now + 2 * DateTime.TicksPerMinute, False)
If(Aan) Then
n.Cancel(1)
Aan=False
Else
DisplayIcon
Aan=True
End If
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
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 DisplayIcon
n.Initialize
n.Icon = "check"
n.SetInfo("CIRIS Example", "Nieuw berichten ontvangen...", Main)
n.AutoCancel = True
n.Notify(1)
End Sub
It is a short code only for testing.
Do I have to reload the layout and how?
Best regards,
André