#Region Project Attributes
#ApplicationLabel: TestLicense
#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.
' ------------------------------------------------------------
' Add the following 2 lines to the manifest
' to start the main activity the next time you run
' SetApplicationAttribute(android:clearTaskOnLaunch, "true")
' ------------------------------------------------------------
' Add #BridgeLogger: True to enable logs in Release mode.
' ------------------------------------------------------------
' Logging is done extensively using Sub AppLog;
' set flag to false to turn logging off
' ------------------------------------------------------------
Public CAPPLOG As Boolean = False
' We used XUI Views library
Private xui As XUI
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.
Private dialog As B4XDialog
End Sub
Sub Activity_Create(FirstTime As Boolean)
dialog.Initialize(Activity)
' Define acceptable days
Dim LifeCycle As Int = 60
' Define the representation of the date
DateTime.DateFormat = "MM/dd/yyyy"
' Replace this with your start date proces
Dim LifeStart As Long = DateTime.Dateparse("12/19/2019")
' AppLog("LifeStart: " & LifeStart)
' Were are we now?
Dim LifeNow As Long = DateTime.Now
' AppLog("LifeNow: " & LifeNow)
' How many days still to go?
Dim RemainDays As Long = LifeCycle - (LifeNow - LifeStart) / 86400000
AppLog("RemainDays: " & RemainDays)
' Are we at end of demo?
If RemainDays < 0 Then
' Create the overdue error message
Dim MsgInfo As String = $"This app is ${NumberFormat(Abs(RemainDays),1,0)} day outdated!
Renew your license now!
More information at:
https://renewyourlicense.com"$
' Show error and wait
' Msgbox2Async(MsgInfo, "License test", "", "", "OK", Null, False)
Dim icon As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "WarningHalt.png", 60dip, 60dip, True)
Dim sf As Object = xui.Msgbox2Async(MsgInfo, "License test", "", "", "OK", icon)
Wait For (sf) Msgbox_Result (Result As Int)
' Terminate all processes
Activity.Finish
' And close the application
ExitApplication
End If
' Create the overdue error message
Dim MsgInfo As String = $"Renew your license within ${RemainDays} days!
More information at:
https://renewyourlicense.com"$
' Prepair icon to display
Dim icon As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "WarningSign.png", 60dip, 60dip, True)
' Inform the user
Dim sf As Object = xui.Msgbox2Async(MsgInfo, "License test", "", "", "OK", icon)
Wait For (sf) Msgbox_Result (Result As Int)
' Only valid users can see the screen so now we can load the screen
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
End Sub
Sub Activity_KeyPress (KeyCode As Int)
If KeyCode = KeyCodes.KEYCODE_BACK Then
' Create the overdue error message
Dim MsgInfo As String = $"Do you really want to close the application?"$
' Prepair icon to display
Dim icon As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "WarningSign.png", 60dip, 60dip, True)
' Inform the user
Dim sf As Object = xui.Msgbox2Async(MsgInfo, "Terminated Application", "Yes", "", "No", icon)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = -1 Then
' Close all processes to exit the application
' Stop all services
' StopService(SQLService)
' Terminate all processes
Activity.Finish
' Leave application
ExitApplication
Else
' Resume application, do nothing
End If
End If
End Sub
' Logging - Set global flag CAPPLOG to False to disable logging
Sub AppLog (sEntry As String)
If CAPPLOG Then
Log(DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now) & " - " & sEntry)
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub