Android Question Menu not showing on new device.

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

I will put this as briefly as possible.

Existing Google map App updated to match changes Google's requirements. [Using Erel's tutorial.]
Menu is Activity. Addmenuitem code and a menu button. There have been no changes to menu code.
On existing devices [LG V20 & Note 3] the menu functions as usual. New device [Galaxy Tab A 10.1"] the menu does not appear when the menu button is pushed.
My first thought was that the menu was hidden by the mapfragment layout [New] but it does not happen in the older devices.

If anyone has an idea of the cause I would be thankful. If is happening to users it is not good. My alternative is to use a side panel instead of the standard menu

Many thanks in advance.

Roger
 

Peter Simpson

Expert
Licensed User
Longtime User
Double check the theme in the manifest @Roger Daley, I presume your target sdk is set to 26?
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Peter,

You still have that scary Avatar.

Copy of the manifest below, it has sort of morphed over time but I can't see anything untoward. I haven't had a "Theme" for a very long time.

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136

 'Changed line as part of upgrade 10 Aug 19
'<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="26"/>
'<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

'This line added as part of upgrade 10 Aug 19
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
'SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.

AddManifestText( <permission
          android:name="$PACKAGE$.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
      <uses-feature android:glEsVersion="0x00020000" android:required="true"/>)
      
AddApplicationText( <meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" /> )
 
   'Changed line as part of upgrade 10 Aug 19
    ' android:name="com.google.android.maps.v2.API_KEY"
AddApplicationText(<meta-data
    android:name="com.google.android.geo.API_KEY"
   android:value="AIzaSyAn4mAf8Nqha2H5oHHYvbCx9Ge37DUMMY"/>)
'<meta-data android:name="com.google.android.gms.version"
'android:value="@integer/google_play_services_version"
'    />)
    
AddPermission(android.permission.ACCESS_NETWORK_STATE)


Regards Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel

I created the menus at the end of Activity_Create.
At the start of mFragment_Ready:
B4X:
gmap = mFragment.GetMap

'   'Added as part of upgrade 10 Aug 19                   
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean) 
    gmap.MyLocationEnabled = Result

I moved the menu creation to the end of mFragment_Ready but no change.

Regards Roger

P.S. The theme didn't change anything.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Try something like this @Roger Daley, this is basically the order I used to fix an issue like yours that I was having.

B4X:
Something like this...

    Activity.LoadLayout("<LAYOUT FILE...>")
    ActivityTitle = "<TITLE>"
    Activity.AddMenuItem("A", "AA")
    Activity.AddMenuItem("B", "BB")
    Activity.AddMenuItem("C", "CC")
    etc
    etc
    etc    

    Sleep(0)
    Wait For (CallSub(Starter, "ConnectTodatabase")) Complete (Result As Object)

I had the exact same issue last year with a clients app, none of the menus would work on their Samsung tablets until I added the Sleep(0), it was working on all my tablets except for Samsung Tab until I added the Sleep(0), then Samsung started working.

It probably will not fix your issues, but you can only give it a try...
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Try something like this @Roger Daley, this is basically the order I used to fix an issue like yours that I was having.

B4X:
Something like this...

    Activity.LoadLayout("<LAYOUT FILE...>")
    ActivityTitle = "<TITLE>"
    Activity.AddMenuItem("A", "AA")
    Activity.AddMenuItem("B", "BB")
    Activity.AddMenuItem("C", "CC")
    etc
    etc
    etc   

    Sleep(0)
    Wait For (CallSub(Starter, "ConnectTodatabase")) Complete (Result As Object)

I had the exact same issue last year with a clients app, none of the menus would work on their Samsung tablets until I added the Sleep(0), it was working on all my tablets except for Samsung Tab until I added the Sleep(0), then Samsung started working.

It probably will not fix your issues, but you can only give it a try...


Peter,

It was worth a try, but unfortunately no go.

B4X:
Sub Activity_Create(FirstTime As Boolean)       
    'Scaling.SetScaleRate(0.5)
    'Ph.SetScreenOrientation(1)        ' portrait orientation only

    Activity.LoadLayout("main")           
    Activity.AddMenuItem("Help", "HelpSub")
    Activity.AddMenuItem("Settings", "SettingsSub")
    Activity.AddMenuItem("About", "About")
    Sleep(0)

Thanks for the try.

Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Please upload a small project that demonstrates the issue.

Erel,

Zip file attached, sorry it's the full project but I figured a new small project would run a high risk of not duplicating the problem.

:Menu operates correctly on Note3 and LG V20 but not on my Galaxy Tab A.
:Other Apps I have written using the same menu code work on the Galaxy. [No GoogleMaps involved]
:Earlier versions of the App where the "Map Fragment" was created in code the menu works. mFragment is now in a panel in a Layout.
:I temporarily set the Map Panel to half width to see if the Menu appears behind the panel. It doesn't.
:The Map Key is a dummy

As usual any hint gratefully accepted.

Roger
 

Attachments

  • ABTtestfile.zip
    296.2 KB · Views: 256
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
The menu is part of the action bar / title bar.

Set:
B4X:
  #IncludeTitle: True


Erel,
This shows the menu coming down from the title and is a possible work-around but doesn't really answer the issue. In this and other apps I have been using a menu button that brings up the menu from the bottom of the screen. [Standard, no big deal].
Now for some strange reason this doesn't work for just one App on a new device. A worry.
I'll keep investigating.

Regards Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
The standard menu in the holo theme and material theme belongs to the action bar. This is how Android works.
On most devices there is no hardware menu button at all and the three dots will not appear if there is no action bar.
Hi Erel,
I think we've drifted off subject. Hardware menu buttons (I had forgotten there were such things) and 3 dots were never the issue.
A loss of function in an app moving from Android 8 to Android 9 is the real issue.
All this could be moot, I've discovered something more drastic which may require me to go back to square one. I am about to dump my current upgrade attempt and start again tomorrow. :mad:

Regards Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

Back on track.
Attached is a sample program showing the menu problem.
When installed on a Note 3 and a LG V20 [Android 5 and 8 respectively] the menu appears. See attached screen shot. When installed on a Galaxy Tab A [Android 9] the menu does not appear.

Is there a Googlemap problem with Android 9? Is there a Galaxy Tab A problem? Does anyone else get the problem?
I can't see how my code could cause the problem [I could be wrong], this may be something that is about the bite a few apps.

Any answer gratefully appreciated.

Regards Roger.
P.S. The Map Key in the manifest is a dummy.
P.P.S. The map doesn't show, I haven't followed up as it is not part of the menu button problem.

Regards Roger

Menu.png
 

Attachments

  • OMTest.zip
    10.4 KB · Views: 251
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel,
You are the expert but I must point out :
1. I have used this method on several Apps for several years.
2. This method still works on my older devices. (Please note the screen shot.)
3. This may not be a Google map issue but I have flagged it as it has only occurred on a google map App after an update. Earlier versions of the same App do not have this issue. Other Apps do not have this issue.
4. I have tried the action /title bar and yes it works (Please note: previously stated in this thread).
5. Using the title bar is one possible solution but does not address the issue.
6. There many Apps out there in Google land without title bars but with menus. Android seems to have been operating this way for many years. What has changed?


I am sorry if you are offended that I don't grab the first alternative you suggest, but I see that as ducking the question.
I would have thought you of all people would want to get to the root cause. For me a work around will have to do.

Regards Roger
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I am sorry if you are offended that I don't grab the first alternative you suggest, but I see that as ducking the question.
Not at all. This is just how Android works. As you pointed out it is not consistent in all versions and devices. However you cannot do anything to get the system menu to work on many devices without the action bar. The solutions are simple. If you don't want to show the built-in action bar then use your own menu. There are many options (B4XDrawer is one).
 
Upvote 0
Top