public void finishActivity (int requestCode)
Since: API Level 1
Force finish another activity that you had previously started with startActivityForResult(Intent, int).
Parameters requestCode
The request code of the activity that you had given to startActivityForResult().
If there are multiple activities started with this request code, they will all be finished.
也许你会这样理解 ,Activity1 通过方法 startActivityForResult (Intent, int) 启动 Activity2,
然后在 Activity2 中通过方法finishActivity (int requestCode)来结束 Activity1,但是很不幸运,不是这样的。不信你可以Demo一把!
上面文档说得很明白,该方法强制关闭通过方法 startActivityForResult (Intent, int) 启动的 Activity,
也就是说在 Activity1 中的(重写)方法 onActivityResult(int requestCode, int resultCode, Intent data) 来接收 Activity2 返回的结果,
必须在 Activity1 中调用 finishActivity (int requestCode) 来结束 Activity2。
(一般在 onActivityResult 方法调用该方法结束 Activity2)。
也可以通过setResult,然后在onActivityResult里面finish掉
参考https://blog.csdn.net/heysuo/article/details/38977821
标签:Activity2,int,requestCode,Intent,startActivityForResult,finishActivity From: https://www.cnblogs.com/kinoyo/p/18233275