I have a problem with Gradle building. When I build my project, it displays the error:
Finish can only be called once in android studio
Anyone have idea about this error?
Android will generally call onPause() if you call finish() at some point during your Activity's lifecycle unless you call finish() in your onCreate() . Run, and observe that your log will only contain "onDestroy". Call finish() almost anywhere else and you'll see onPause() called.
On Clicking the back button from the New Activity, the finish() method is called and the activity destroys and returns to the home screen.
Using activity. isFinishing() is the right one solution. it return true if activity is finished so before creating dialog check for the condition.
in android studios go to ....
file > invalidate caches and restart ....
click invalidate and restart button in confirmation dialog..
might take few time to build Gradle..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With