Android:将数据传递给子活动,检测谁是父项

Tro*_*roj 0 android android-activity

如果有可能知道我从哪个家长来自孩子那么我可以知道,所以我可以根据父母的活动来做不同的事情.

这就是Iam对孩子的看法.但是我不知道如何在孩子中处理这个以检查谁是父母.

    public void chooseLocation(View v){
    Intent i = new Intent();
    i.setClass(InsertAd.this, Location.class);
    startActivityForResult(i, REQ_CODE_SELECT_LOCATION);
}
Run Code Online (Sandbox Code Playgroud)

以上代码用于其中一个父母,是否有某种方式我可以使用"EQ_CODE_SELECT_LOCATION"?

我还想知道如何将数据发送到子活动?

xan*_*ndy 5

放入额外的传递额外数据的意图.例如:

Intent i = new Intent();
i.putExtra("CallerClass", "com.example.callingActivity");
...
Run Code Online (Sandbox Code Playgroud)

稍后在Location.class中,您可以通过getIntent()检索这些额外的内容

string caller = getIntent.getExtras().getString("CallerClass");
Run Code Online (Sandbox Code Playgroud)