Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Options Menu shows slowly

Tags:

android

menu

In my Android Application I want to have a options menu in the toolbar and the functionality works just fine. However it takes a considerably long time (about one second) until the menu show after the 3 dots in the toolbar are pressed.

At first i thought, that it might be some problem specific to my app, but I created a new project from the Android Studio template and the problem still persists. (Though it feels a little bit faster than in my application)

The menu is created as documented in the docs:

menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/manageBTConnection"
        android:icon="@drawable/ic_bluetooth_white"
        android:orderInCategory="100"
        android:title="@string/connect"
        app:showAsAction="ifRoom" />

    <item
        android:id="@+id/backgroundService"
        android:title="Start background service" />

    <item
        android:id="@+id/sendToBackend"
        android:title="Send to Backend" />

</menu>

MainActivity

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.menu, menu);

        return true;
    }

Compared to other Android apps it takes a lot longer than usual and feels clunky.

Is there any way to speed up the creation/showing of the dropdown menu?

Many thanks!

like image 364
Maximilian Speicher Avatar asked Jul 05 '19 08:07

Maximilian Speicher


1 Answers

I'm experiencing the same thing. Here I've profiled what happens when I tap to open the menu. Notice that it takes 900 to 1000 milliseconds for the menu to appear.

enter image description here

like image 85
Tyler Avatar answered Nov 14 '22 15:11

Tyler