使用意图将数据发送到我的活动 [英] Use an intent to send data to my activity

查看:114
本文介绍了使用意图将数据发送到我的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务器上运行,通知与打开我的主要活性状态栏通知用户,我怎么可以将数据传递给我的活动低谷意图是什么?

I have a server running that notifies the user with a statusbar notification that opens my main activity, how can I pass data to my activity trough that intent?

推荐答案

使用<一个href="http://developer.android.com/reference/android/content/Intent.html#putExtra%28java.lang.String,%20java.lang.String%5b%5d%29">Intent.putExtra(..):

intent.putExtra("keyName", "somevalue");

此方法重载,需要各种类型的第二个参数:INT,字节,字符串,在不同的阵列。

This method is overloaded and takes various types as second argument: int, byte, String, various arrays..

要获取数据使用适当的getXYZExtra()。对于字符串,这是:

To get the data out use appropriate getXYZExtra(). For String this is:

getStringExtra(String keyName)

这篇关于使用意图将数据发送到我的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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