Android: Pass data to a child activity, Detect who is the parent
I wounder if there is some possible to know from which parent Iam coming from in the child so I can do different stuff depending on who the parent is of the activity..
This is how Iam going over to the child. But I don't know how to handle this in the child to check who is the parent.
public void chooseLocation(View v){
Intent i = new Intent();
i.setClass(InsertAd.this, Location.class);
startActivityForResult(i, REQ_CODE_SELECT_LOCATION);
}
The above code is used on one of the parents,, is th开发者_运维百科ere somehow I can use "EQ_CODE_SELECT_LOCATION"?
Also I wounder how is possible to send data to a child activity?
Put in Extra of your intent to pass extra data. eg:
Intent i = new Intent();
i.putExtra("CallerClass", "com.example.callingActivity");
...
and later in your Location.class, you can retrieve those extra via getIntent()
string caller = getIntent.getExtras().getString("CallerClass");
精彩评论