我如何通过活动之​​间的数据在Android? [英] How do I pass data between activities on Android?

查看:260
本文介绍了我如何通过活动之​​间的数据在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,通过登录页面登录后,会有一个退出按钮在每个活动。

I have a scenario where, after logging in through a login page, there will be a sign out button on each activity.

在单击signout,我会传球的签约用户的会话ID signout。任何人都可以指导我如何保持会话ID提供给所有的活动??

On clicking signout, I will be passing the session id of the signed in user to signout. Can anyone guide me on how to keep session id available to all activities??

另外,有另一种解决这个问题?

Alternatively, is there another solution to this problem?

推荐答案

这样做将是会话ID传递到您正在使用启动该​​活动的意图signout活动的最简单的方法:

The easiest way to do this would be to pass the session id to the signout activity in the intent you're using to start the activity:

Intent intent = new Intent(getBaseContext(), SignoutActivity.class);
intent.putExtra("EXTRA_SESSION_ID", sessionId);
startActivity(intent)

借助文档的意图有更多的信息(看标题为其他)。

The docs for Intents has more information (look at the section titled "Extras").

这篇关于我如何通过活动之​​间的数据在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆