如何从拉包串中onResume()? [英] How to pull string from bundle in onResume()?

查看:150
本文介绍了如何从拉包串中onResume()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户选择一个联系人后恢复活动。现在,用户选取前接触onSavedInstanceState叫我放在包的字符串。现在,用户经过选择的接触,其结果被返回。 onRestoreInstanceState犯规被调用。只有onResume()被调用。所以,我怎么会去一次活动继续拉我的字符串背出束?

I have an activity that is resumed after a user picks a contact. Now before the user picks a contact onSavedInstanceState is called and i put a string in the Bundle. Now, After the user selects the contact and the results are returned. onRestoreInstanceState doesnt get called. only onResume() gets called. So how would i go about pulling my string back out of the bundle once the activity is resumed?

推荐答案

比方说你有两个活动A和B,如果你想从一个信息传递给B,可以从信息传递活动A开始活动B. A到用b:

Lets say you have two Activities A and B, and Activity A starts Activity B. If you want to pass information from A to B, you can pass information from A to B with:

Intent i = new Intent(this. ActivityB.class);
i.putExtra("Key","Value");
startActivity(i);

然后在活动B你可以得到字符串

Then in Activity B you can get the string with

String value = this.getIntent().getExtras().getString("keyName");

不过,如果你想从B到A的传递信息,你必须使用不同的方法。而不是使用 startActivity 你需要使用 startActivityForResult 。这种方法的说明这里找到:<一href=\"http://stackoverflow.com/questions/2497205/how-to-return-a-result-startactivityforresult-from-a-tabhost-activity\">How从TabHost活动返回结果(startActivityForResult)?

However, if you want to pass information from B to A you have to use a different method. Instead of using startActivity you need to use startActivityForResult. A description of this method is found here: How to return a result (startActivityForResult) from a TabHost Activity?

这篇关于如何从拉包串中onResume()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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