开发者

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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜