0

I have an activity with buttons on them. When I click the button the text of the buttons change. I am adding a share menu to share the new values of the buttons with other apps. Whenever I try to access the text values of the buttons in onCreateOptionsMenu I get the original values and not the new values.

How can I access the new values?

jww
  • 97,681
  • 90
  • 411
  • 885
user1253073
  • 374
  • 2
  • 6
  • 26
  • `The onCreate method is called first, and before it finishes onCreateOptionsMenu is called.` Basically you're getting the original values because at the time onCreateOptionsMenu is called, the values haven't changed yet. Try calling `invalidateOptionsMenu();` after changing the values; this will cause onCreateOptionsMenu to be called again. – Matter Cat Apr 13 '15 at 01:13

2 Answers2

1

onCreateOptionsMenu() is called when the menu is first created. At that time, the text in the buttons is the original one. So you should call invalidateOptionsMenu(); each time you click the button and the text is changed. See this.

Community
  • 1
  • 1
Kartik
  • 7,677
  • 4
  • 28
  • 50
0

Do you want to share variables to another apps?
You can use putExtra in Intent or Share preferences.
Try this topic How to send data from one application to other application in android?

Community
  • 1
  • 1
thienkhoi tran
  • 341
  • 2
  • 9