Android Question Msgbox is depricated

peacemaker

Expert
Licensed User
Longtime User
HI, All

1) Does it mean that "Msgbox" code is just ignored now by the compiler ?

2) If yes - how to make the situation of the full app stop, when no running just after "OK" button tap is required ? Say, some app work limit and after "OK" button the app exit must be done - seems, it's impossible now ? As MsgBoxAsync allows code execution in the background, but the full stop is required.
How to be ?
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
1. No

The simple solution is: Switch to msgboxasync or LOGging. Do not use MsgBox any longer.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
B4X:
Sub Activity_Resume
If Outdated Then 'full version
    Activity.Finish
    ExitApplication
End If
End Sub

Sub Outdated As Boolean
If DateTime.GetMonth(DateTime.Now) <> 2 Then
    Msgbox(Application.LabelName & ": this app version is outdated, update.", "Stop:")
    Return True
Else
    ToastMessageShow("Demo...", False)
    Return False
End If
End Sub

Actually, if the full execution stop is needed - the indeed modal dialog is required :( that stops the user fully.
In this code - how to interrupt the app work without "Msgbox"?
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
No, it´s nothing about hate. I´ve finished with our disputes years ago. I am just not interested in your posts. Usually unuseful, sometimes telling total bullshit. Sometimes there are for sure useful Posts too; but rare.

I decided for myself to better fully ignore your Content. That´s all ? ?
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I prefer not to ignore anyone and be able to enjoy your delicious phrases, like this:
No, it´s nothing about hate. I´ve finished with our disputes years ago. I am just not interested in your posts. Usually unuseful, sometimes telling total bullshit. Sometimes there are for sure useful Posts too; but rare.

I deviced for myself to better fully ignore your Content. That´s all ? ?
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
I also ran into peacemaker question in some older programs of mine:
how to interrupt the app work without "Msgbox"?

Perhaps is this a possible solution:

Possible solution for how to interrupt the app work without "Msgbox":
#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

I notice that on two different phones with different Android OS versions, that not all processes "disappear" from the installed app. What stays behind seems to be "dead" without displaying the screen content of the last session. Unfortunately could not find a solution for this.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
I also ran into peacemaker question in some older programs of mine:
@DonManfred has already given you the answer, and a quick forum search (about 20 seconds) brings back lots of results including this one.
 
Upvote 0
Top