I've an activity with ACToolbar Menus
I've been testing code that restores state, and everything works as expected on API > 19. On Android 4.4.4 (and probably any API 19 I guess) the restoration of the appropriate menu for the State is being messed up by there being 2 calls to Activity_CreateMenu.
The attached project shows what I'm seeing, 1 call to Activity_CreateMenu on Android 5, 6 & 7 and 2 calls to Activity_CreateMenu on 4.4.4
Does anyone have any idea why this is happening and how to prevent it?
This is the example code:
I've been testing code that restores state, and everything works as expected on API > 19. On Android 4.4.4 (and probably any API 19 I guess) the restoration of the appropriate menu for the State is being messed up by there being 2 calls to Activity_CreateMenu.
The attached project shows what I'm seeing, 1 call to Activity_CreateMenu on Android 5, 6 & 7 and 2 calls to Activity_CreateMenu on 4.4.4
Does anyone have any idea why this is happening and how to prevent it?
This is the example code:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#Extends: android.support.v7.app.AppCompatActivity
#End Region
#If Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
if (processBA.subExists("activity_createmenu")) {
processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
return true;
}
else
return false;
}
#End If
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.
Private ToolBar As ACToolBarLight
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("Listviewer")
End Sub
Sub Activity_Resume
Log("Activity_Resume Code End")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
#IgnoreWarnings: 11
Sub Activity_CreateMenu(Menu As ACMenu)
Log("Activity_CreateMenu Start")
Menu.Clear
Dim item As ACMenuItem
Menu.AddWithGroup2(0, 10, 0, "Menu1", Null)
Menu.AddWithGroup2(1, 20, 0, "Menu2", Null)
Menu.AddWithGroup2(2, 30, 0, "Menu3", Null)
End Sub
Attachments
Last edited: