相关疑难解决方法(0)

如何在Android应用程序中的活动之间传递数据?

我有一个场景,通过登录页面登录后button,每个都会有一个注销activity.

点击后sign-out,我将通过session id已登录用户登出.任何人都可以指导我如何让session id所有人都可以使用activities吗?

任何替代这种情况

android android-intent android-activity

1293
推荐指数
29
解决办法
88万
查看次数

通过bundle传递值并获取其他活动的值

正如我在代码中看到的那样,我正在通过Bundle传递价值.
现在,我希望它在另一项活动中具有价值onCreate().我尝试了它的值,但它显示nullpointerexception.

请帮我解决问题.

Bundle bundle = new Bundle();
String url = "http://www.google.com";
bundle.putString("url", url);
Intent myIntent = new Intent(context, NotificationService.class);
myIntent.putExtras(bundle);
context.startService(myIntent);
Run Code Online (Sandbox Code Playgroud)


获取价值代码:

if (!getIntent().getExtras().getString("url").contains(null)) {
        // Do something
}
Run Code Online (Sandbox Code Playgroud)

android android-intent

13
推荐指数
3
解决办法
7万
查看次数

标签 统计

android ×2

android-intent ×2

android-activity ×1