简体   繁体   English

如何将数据传回父活动

[英]How to pass data back to parent activity

On my app I see having multiple activities... 在我的应用程序上,我看到有多个活动......

            Main
              |
     --------------------
   Login                 |
     |                   |
     --------------- Dashboard
                         |
     -----------------------------------------
     |                   |                   |
 Activity1           Activity2            Activity3

If a user is logged in, it will bypass login and head straight to dashboard. 如果用户已登录,则会绕过登录并直接进入仪表板。 Then I see the dashboard launching other activities. 然后我看到仪表板启动了其他活动。 Currently, my main activity looks like: 目前,我的主要活动如下:

public class MainActivity extends Activity {
    User user = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        startActivity(new Intent(this, LoginActivity.class));
    }
}

I've tried to find sample code showing how to pass data from my login activity back to Main, but I've been struggling. 我试图找到示例代码,显示如何将数据从我的登录活动传递回Main,但我一直在努力。 I can find many examples of how to pass data from a parent activity to a child activity, but not the other way around. 我可以找到许多如何将数据从父活动传递到子活动的示例,但不是相反。

PS - If I'm not on the right track with my app, please let me know! PS - 如果我的应用程序没有走上正轨,请告诉我!

Have you looked into startActivityForResult? 你看过startActivityForResult了吗?

Please see this tutorial: http://www.mybringback.com/tutorial-series/12186/android-startactivityforresult-example/ 请参阅本教程: http//www.mybringback.com/tutorial-series/12186/android-startactivityforresult-example/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从子活动传递到父活动 - Pass data from sub activity to parent activity 如何将数据从表面视图传递到其父活动? - How pass data from surface view to its parent activity? 将其他数据从可穿戴设备传递回活动 - Pass additional data back from Wearable to Activity 在活动中按下时如何将数据从活动传递到片段? - android - How to pass data from activity to Fragment when pressed back in activity ? - android 将自定义对象的 ArrayList 从子活动传回父活动 - Pass ArrayList of custom objects from child activity back to parent 将数据从“活动”传递到带有“活动”的片段,然后在选择了选项后返回 - Pass data From Activity, to Fragment with Activity, then back once option is selected 如何将值从父级活动传递到子级活动,以及如何在子级活动退出时刷新父级活动 - How to pass value from parent activity to child activity and on child activity exit, refresh the parent activity 如何从地图活动中获取所选位置并将其传递给父活动? - How to get selected location from map activity and pass it to a parent activity? 如何在TAB应用程序中按下chlild活动上的按钮时返回到父活动 - how to return back to parent activity while pressing back button on chlild activity in TAB Application 如何通过后退操作栏按钮 go 回到活动而不重新创建父活动 - How to go back to a activity through the back action bar button without recreating the Parent activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM