I have NewMessage Activity
from which I am calling Tab Activity. Tab Activity Contains 3 Tab Contacts|Group|Selected Contacts
I will select some contacts on contact tab and will redirect those contacts to NewMessage
again. This thing is working fine without Tab Activity.
I refer some link
stuck with getting camera pic when using the tab Activity
Android onActivityResult is always 0
My Code:
To Call The Tab Activity
Intent i = new Intent(this,Tab.class);
startActivityForResult(i, REQUEST_PICK_CONTACT);
Tab.Class
public class Tab extends TabActivity {
/** Called when the activity is first created. */
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
android.app.ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
TabHost tabHost = getTabHost();
// Tab for Photos
TabSpec PhoneBook = tabHost.newTabSpec("PhoneBook");
PhoneBook.setIndicator("PhoneBook");
Intent PhoneBook = new Intent(this, Tab1.class);
PhoneBook.setContent(photosIntent);
// Tab for Songs
TabSpec Groups = tabHost.newTabSpec("Groups");
// setting Title and Icon for the Tab
Groups.setIndicator("Groups");
Intent Groups = new Intent(this, Tab2.class);
Groups.setContent(Groups);
// Tab for Videos
TabSpec SelectedContacts = tabHost.newTabSpec("Selected Contacts");
SelectedContacts.setIndicator("Selected Contacts");
Intent SelectedContacts = new Intent(this, Tab3.class);
SelectedContacts.setContent(videosIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(PhoneBook); // Adding PhoneBook
tabHost.addTab(Groups); // Adding Group PhoneBook
tabHost.addTab(SelectedContacts); // Adding SelectedContacts
}
//Menu Bar
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.contact_list, menu);
return super.onCreateOptionsMenu(menu);//This is actionBar Save Button
}
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
//Save Button Click
if (id == R.id.action_done)
{
Log.d("Activity","Tab");
}
return super.onOptionsItemSelected(item);
}
}
This is the Tab1.Class From which I need to pass on value ActionBar Save Button Click.
I have declare action_bar save button in Tab.Class because if I declare it in Tab1.class its not showing up.This is the code which I return back on save button Click
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
//Save Button Click
if (id == R.id.action_done)
{
for(int i = 0; i < ViewContactName.size(); i++)
{
if(ma.mCheckStates.get(i)==true)
{
SelectedName.add(ViewContactName.get(i));
SelectedPhoneNumber.add(ViewContatcPhnoeNo.get(i).replaceAll("[^0-9,+]", ""));
}
}
Intent intent = new Intent();
intent.putStringArrayListExtra("ContactName",(ArrayList<String>) SelectedName);
intent.putStringArrayListExtra("ContactNumber", (ArrayList<String>) SelectedPhoneNumber);
setResult(RESULT_OK, intent);
finish();
}
return super.onOptionsItemSelected(item);
}
So what can be the solution? I used TabHost