Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Finish can only be called once

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?

like image 465
Phạm Lam Avatar asked Mar 06 '17 10:03

Phạm Lam


People also ask

Does finish call onPause?

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.

What does finish () do Android?

On Clicking the back button from the New Activity, the finish() method is called and the activity destroys and returns to the home screen.

How do you check if activity is finished or not?

Using activity. isFinishing() is the right one solution. it return true if activity is finished so before creating dialog check for the condition.


1 Answers

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..

like image 81
harsh patel Avatar answered Oct 08 '22 03:10

harsh patel