Reputation: 487
I have this parent tab from which I want to send a boolean value to one of my tabs. How do I do it? I this the following would work, but obviously it doesn't!
Here's the parent tab (IncludeTabActivity.java):
Intent i = getIntent();
i.putExtra("FromMyActivity", fromLogin);
TabActivity ta = (TabActivity) IncludeTabActivity.this;
ta.getTabHost().setCurrentTab(0);
Here's the child tab:
Bundle extras = getIntent().getExtras();
boolean fromLogin = extras.getBoolean("FromMyActivity");
How could this be done?
Upvotes: 1
Views: 881
Reputation: 1600
The way I would receive the data is sleightly different.
Intent received = getIntent();
boolean dataReceived = received.getExtra("FromMyActivity");
Upvotes: 0
Reputation: 316
Try:
SharedPreferences settings = getSharedPreferences("DefaultSettings", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("FromMyActivity", fromLogin);
editor.commit();
then to get it use
SharedPreferences settings = getSharedPreferences("DefaultSettings", 0);
boolean fromLogin = settings.getBoolean("FromMyActivity", defaultFromLoginValue);
Upvotes: 2