Android Question Error before loading B4XMainPage

Nitin Joshi

Active Member
Licensed User
Longtime User
I am not able to get the reason for following while i run the B4A program. Following is the only code in Main Module

Main Module Code:
Sub Process_Globals
    Public ActionBarHomeClicked As Boolean
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
End Sub

B4A line: 23
End Sub
shell\src\b4a\example\main_subs_0.java:170: error: method _process_globals in class b4xmainpage_subs_0 cannot be applied to given types;
b4xmainpage_subs_0._process_globals();
^
required: RemoteObject
found: no arguments
reason: actual and formal argument lists differ in length
1 error
 
Solution
You can create all your variables in Class_Globals of the B4XMainpage.

If you want to create a variable in Main, you can do it on the MAIN Module in the Process_Globals or Globals there, and call it anywhere by referencing the Module

B4X:
log(Main.myvariable)

mcqueccu

Well-Known Member
Licensed User
Longtime User
Following is the only code in Main Module

B4A Main Module contains more codes than what you posted above, so its not the only code as you said. Here is the complete code you should see in Main.
You don't delete or modify anything in Main Module.


B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #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

'#BridgeLogger: True

Sub Process_Globals
    Public ActionBarHomeClicked As Boolean
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
End Sub

'Template version: B4A-1.01
#Region Delegates

Sub Activity_ActionBarHomeClick
    ActionBarHomeClicked = True
    B4XPages.Delegate.Activity_ActionBarHomeClick
    ActionBarHomeClicked = False
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Sub Activity_Resume
    B4XPages.Delegate.Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    B4XPages.Delegate.Activity_Pause
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub

Sub Create_Menu (Menu As Object)
    B4XPages.Delegate.Create_Menu(Menu)
End Sub

#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
     processBA.raiseEvent(null, "create_menu", menu);
     return true;
    
}
#End If
#End Region

'Program code should go into B4XMainPage and other pages.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
You can create all your variables in Class_Globals of the B4XMainpage.

If you want to create a variable in Main, you can do it on the MAIN Module in the Process_Globals or Globals there, and call it anywhere by referencing the Module

B4X:
log(Main.myvariable)
 
Upvote 0
Solution

Nitin Joshi

Active Member
Licensed User
Longtime User
Thanks. yes it worked. It means Process_Global and Global should not be part of Pages, is my understanding correct?
 
Upvote 0
Top