Android Question update the global variables

mmrafiei

Member
MY CODE:
#Region  Project Attributes
    #ApplicationLabel: BASEproject
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #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.
    
    Dim Timer1 As Timer
    Dim TIMEvalue As Int
    
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.

    Private Connect As Button
    Private Disconnect As Button
    Private AUTO As Button
    Private Manual As Button
    Private ImageAUTO As ImageView
    Private ImageConnect As ImageView
    Private ImageDisconnect As ImageView
    Private ImageManual As ImageView
    Private LabelABOUT As Label
    Private CircularProgressBar1 As CircularProgressBar
    
    Private ManualON As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    Activity.LoadLayout("Layout")
    Activity.AddMenuItem("home", "eventHOME")
    Activity.AddMenuItem("timer", "eventTEMP")
    Activity.AddMenuItem("about", "eventABOUT")
    Activity.AddMenuItem("exit", "eventEXIT")
    
    Timer1.Initialize("eventTIMER" , 1000)
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub eventTIMER_Tick

    TIMEvalue = TIMEvalue + 1
    
End Sub

Sub eventHOME_Click
    
    Activity.RemoveAllViews
    
    Activity.LoadLayout("Layout")
        
End Sub

Sub eventABOUT_Click
    
    Activity.RemoveAllViews
    
    Activity.LoadLayout("Layout3")
    
    LabelABOUT.Text = "POWERED BY ❤️LOVE"
    
        
End Sub

Sub eventTIME_Click

    Activity.RemoveAllViews
    Activity.LoadLayout("Layout2")
        
        CircularProgressBar1.Value = TIMEvalue
    
End Sub

Private Sub ManualON_Click
    
    Timer1.Enabled = True
    
End Sub

Sub eventEXIT_Click

    
End Sub

Private Sub Connect_Click

    
End Sub

Private Sub Disconnect_Click
    
    
End Sub

Private Sub AUTO_Click
    
    
End Sub

Private Sub Manual_Click
    
    
End Sub


hi,

How can update the global variables automatically.

My code only updates my timer variables once. I want it to be updated automatically

please look at my code and guide me.

LINE 86-99
 

Sagenut

Expert
Licensed User
Longtime User
Code for timer look correct.
Try this:

B4X:
Sub eventTIMER_Tick

    TIMEvalue = TIMEvalue + 1
    Log(Timevalue)
End Sub
so you will have the proof that it's increasing every second.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Note that lines 86-99 are not related to the timer.
You have created 2 extremely similar Sub names:
EventTimer
EventTime
This can give you very hard times while trying to find errors.
 
Last edited:
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
To help you in the best way you should share your project to let us check it.
With a brief explanation of what it should do.
If your project is with activity (Default) you can share it with Export as Zip from the Tools menu.
It will create the zip file of your project to post here.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
The circular progress bar will never be updated because it's called only once.
You should put it in the Timer Tick Sub
B4X:
Sub eventTIMER_Tick

    TIMEvalue = TIMEvalue + 1
    CircularProgressBar1.Value = TIMEvalue
End Sub
But I am just guessing.
 
Upvote 0
Top