0

How can i launch an activity from the same activity under some condition using menu items. Eg:- I have an activity, which could be launch in two conditions based on the value boolean variable 'flag'. The value of this flag can be "true" or "false". If flag is "false" then in menu option icon/text for this activity should be disable. Means i should not be able to launch activity. And if flag is "true" then Menu option for this activity should be Enabled and i should be able to launch the same activity using menu items. (Note: In both the case activity should have same contents but only page header will be different.)

thanks,

Avnish
  • 81
  • 1
  • 2
  • 6

2 Answers2

0

If you your activity behavior depends on sigle boolean - pass it to the activity and handle botch cases. For how to pass data to activity check this question How do I pass data between Activities in Android application? .

Community
  • 1
  • 1
Mojo Risin
  • 8,136
  • 5
  • 45
  • 58
0

In Method OnPrepareOptionMenu(Menu menu) you can add or remove menu Item depends on your flag value.

Mohit
  • 634
  • 5
  • 15