Android的GET previous活动 [英] Android get previous activity
本文介绍了Android的GET previous活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个活动(活动1,活性2) 在每一个这样的活动是谁使我第三个活动按钮(MainActivity) 在MainActivity我想知道从哪个活动页面被调用。
I have 2 activities (Activity1, Activity2) In each of this activities is a button who lead me to a third activity (MainActivity) In MainActivity i want to know from which activity page was called.
推荐答案
您可以使用意向的putExtra属性传递活动的名称。
You can use the putExtra attribute of the Intent to pass the name of the Activity.
调用活动,
Intent intent = new Intent(this, Next.class);
intent.putExtra("activity","first");
startActivity(intent);
下一个活动,
Next Activity,
Intent intent = getIntent();
String activity = intent.getStringExtra("activity");
现在在字符串的活动,你会得到它的活动已经来到了这个名字。
Now in the string activity you will get the name from which Activity it has came.
这篇关于Android的GET previous活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文