3

I want to know if there's any way in Android to programatically know if
public boolean onCreateOptionsMenu(Menu menu) has been called and returned.

I'm using actionsherlockbar library in a project and the app has to download some content and I'd like to start the download when the action bar is loaded so I can use its integrated progress interface, but I can't find a way since onCreateOptionsMenu is called after onCreate.

To sum up, hat I want to do is:

-load the actionBar -notice it is loaded -enable the progress bar -download -disable the progress bar

But I don't know how to notice it's loaded.

Thanks in advance for your help.

LuthorMithos
  • 159
  • 1
  • 2
  • 9
  • Refer this http://stackoverflow.com/questions/7705927/android-when-is-oncreateoptionsmenu-called-during-activity-lifecycle – Ritesh Gune Aug 29 '13 at 09:38
  • Just create a boolean outside of any methods(class scope) defaulted to false and right before the return statement set it to true or if you need to call a method then just call it right from the `onCreateOptionsMenu`. By the way it is called during `onCreate`, so it'll probably be finished by the end of `onCreate`. – Dylan Vander Berg Aug 10 '15 at 19:19

1 Answers1

0

use Log.d() method to register in the logcat. eg:

in your case:

where you have defined the onCreateOptionsMenu() add this command:

Log.d("tag of your choice", "value you want to check if it has been initialized");

You can see more about this function in eclipse or https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCwQFjAA&url=http%3A%2F%2Fdeveloper.android.com%2Freference%2Fandroid%2Futil%2FLog.html&ei=3RIfUqaCGcS4rgf19ICQCg&usg=AFQjCNEd4hTMzjI2BnTS2woBfjvrddoQsw&sig2=4JDVD0JjIjx0mEhog9plPQ&bvm=bv.51495398,d.bmk

Langusten Gustel
  • 10,917
  • 9
  • 46
  • 59