如何将数据发送到Android上创建的活动 [英] How to send data to created activity on Android
本文介绍了如何将数据发送到Android上创建的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从EditText上的活性的数据发送到活动B.
我想:
I need to send data from EditText in activity A to Activity B. I tried:
Intent intent1=new Intent(A.this,B.class);
intent1.putExtra("fromA", "text");
startActivity(intent1);
但它不工作,因为活动B有的android:launchMode =singleTask
和对以前创建
怎么回事,我可以发送数据?
How else, can I send data?
推荐答案
您覆盖 onNewIntent()
在活动B
和接收意图
该方法。
You override onNewIntent()
in the Activity B
and receive the intent
in that method.
下面一样code:
@Override
protected void onNewIntent(Intent i)
{
String s = i.getStringExtra("fromA");
}
在上面的code你会得到价值取值
从活动A
。
In the above code you will get value to s
from Activity A
.
这篇关于如何将数据发送到Android上创建的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文