Whats the difference between finish() and finishActivity(int requestCode) in android

前端 未结 4 1067
失恋的感觉
失恋的感觉 2020-12-16 11:09

Can anyone explain me the difference between finish() and finishActivity(int requestCode). And the situation of where to use them aptly.

Th

4条回答
  •  余生分开走
    2020-12-16 11:29

    So basically you can call other Activities in Android from another Activity via an Intent in Android. When you call startActivityForResult, you're calling another Activity in hopes that a result of code/change in the state of your app will happen. For example, I run my Main Activity, however I call another Activity that sets various fields/variables in the app to certain values (i.e. a user setting up the app's settings). Then, when that Activity has finished and you must return to the Activity that invoked it, you may call finishActivity to send a requestCode that will flag whether the Activity invoked has performed in a way that you desired.

提交回复
热议问题