使用意图将数据发送到我的活动我的、发送到、意图、数据

2023-09-12 04:41:33 作者:弌魜縯繹獨桷戲さ

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

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?

推荐答案

使用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)