I have two Activities in which I want to call the second one from the first one's Context Menu. This is what it should do.
Activity A Context Menu click should start Activity B.
In the onCreate of Activity B, depending on the extras passed in, automatically display a AlertBuilder dialog and then either take a picture or select an image.
What is happening is that when Activity A's Context Menu item is clicked, it launches Activity B and the AlertDialog displays. If I select the option to take a picture, the MediaStore.ACTION_IMAGE_CAPTURE intent is started and once the picture is taken, Activity B is re-launched again and the AlertDialog shows.
Activity A - Context Menu
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
final ItemClass selItem = (ItemClass)this.getListView().getItemAtPosition(info.position);
Intent intent;
SyncData sync;
switch (item.getItemId()) {
case R.id.start_activity_b:
Intent intent = new Intent(ActivityA.this, ActivityB.class);
intent.putExtra("data1", selItem.itemID);
intent.putExtra("data2", "AUTO");
Measurements.this.startActivityForResult(intent, REQUESTCODE_ACTIVITYB);
return true;
default:
return super.onContextItemSelected(item);
}
}
Activity B - onCreate Code
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.listview_main);
Bundle extras = getIntent().getExtras();
if ((extras != null) && (extras.containsKey("data1"))) {
this.itemID = extras.getString("data1");
}
if ((extras != null) && (extra.containsKey("data2"))) {
this.createAlertDialog();
}
}