我已经启动了结果活动,但如何从该活动返回类似参数的字符串?
只需使用以下代码块:
Intent intent=new Intent();
intent.putExtra("RESULT_STRING", string);
setResult(RESULT_OK, intent);
finish();
在调用活动的 onActivtyResult 方法中从此意图获取值:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CREATE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
//Use Data to get string
String string = data.getStringExtra("RESULT_STRING");
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)