【问题标题】:Android: Pass data to a child activity, Detect who is the parentAndroid:将数据传递给子活动,检测谁是父母
【发布时间】:2010-11-02 09:06:57
【问题描述】:

如果有可能知道孩子的父母来自哪个父母,我会很伤心,所以我可以根据活动的父母是谁做不同的事情..

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

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

以上代码用于其中一位父母,有什么办法可以使用“EQ_CODE_SELECT_LOCATION”吗?

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

【问题讨论】:

    标签: android android-activity


    【解决方案1】:

    输入额外的传递额外数据的意图。例如:

    Intent i = new Intent();
    i.putExtra("CallerClass", "com.example.callingActivity");
    ...
    

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

    string caller = getIntent.getExtras().getString("CallerClass");
    

    【讨论】:

    • 是否需要使用onActivityResult=
    • 如果需要返回结果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-07
    • 2021-10-16
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    • 2023-02-08
    • 2021-09-13
    相关资源
    最近更新 更多