java 如何从意图对象android获取请求代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17155661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-01 01:10:26 来源:igfitidea点击:
how to get request code from an intent object android
提问by Priyesh
can anyone tell how can we get the requestcodefrom an Intentwhich we passed from another activity??
谁能告诉我们如何从我们从另一个活动传递的Intent 中获取请求代码?
回答by pt2121
If you do
如果你这样做
intent.putExtra("requestCode", requestCode);
You can get it by doing:
您可以通过执行以下操作来获取它:
int requestCode = getIntent().getExtras().getInt("requestCode");
Or
或者
If you do startActivityForResult like this:
如果你这样做 startActivityForResult 像这样:
startActivityForResult(intent, requestCode);
The request code is there as parameter:
请求代码作为参数存在:
protected void onActivityResult(int requestCode, int resultCode, Intent data)