Reputation: 459
I have 3 tabs (act1,act2,act3) and i have activities without tabs(A,B), if the user open activity A and press button OK then alarm will start and after 10 seconds it will go to act2
this all done, but i tried many thing :
1- when i go to act2 it does not display the tabs. just act2 activity
so i change the code and tried to : 2- when i go to activity tabs it show me the first tab(act1) but i wanna act2
how can i do it i wanna display act2 with tab
Give me any reference or hint.
Thanks in Advance.
Upvotes: 0
Views: 2437
Reputation: 4705
Try this: Send an intent (via startActivity() as usual) to bring the activity to the front which contains the tabs. Send an extra parameter with the activity containing the TAG or some identifier for tab, you want to be opened. Evaluate the extra parameter in the activity, which contains the tab and let it switch to the tab as indicated by the parameter.
EDIT
To start the tab activity with a parameter:
final Intent i = new Intent(this, YourTabActivity.class);
i.putExtra(TAB_TAG, tag); // TAB_ID see comment below, define some tags for the tabs
this.startActivity(i);
To extract the parameter from the intent:
Overwrite onNewIntent()
in the tab activity and introduce a field lastIntent
, set this.lastIntent = this.getIntent()
there. (Otherwise you will always access the intent which started the activity in the first place, not the most recently sent intent!)
in onResume
process the last intent:
final Bundle extras = this.lastIntent.getExtras();
final String tabTag = extras.getString(TAB_TAG); // define the key TAB_TAG as static string
Now use tabTag
to set the current tab.
Upvotes: 3