Check Mobile App
Read now
Start a Project

Activity has leaked window

Save

The most common issue which leads your android application to crash with this log message:

Error: E/WindowManager: android.view.WindowLeaked: Activity com.example.android has leaked window

com.android.internal.policy.PhoneWindow$DecorView{c75fa80 V.E……

Let’s take an example here is request() method where we have requested to the server and showing a progress bar. Here mProgress is an instance of ProgressDialog and getResponse() is a method in which we get a response from the server if error(0) that mean we can start new activity for the user.

In above code, we are showing the progress bar to the user and started the new activity without dismissing progress which leaked window in this case.

Prevention:

onStop() method Activity cycle called when no longer activity visible there we can check either mProgress is null or not. If mProgress isn’t null that mean your activity leaked window so you can dismiss it onStop() method.

Example:

If you have any doubt comment below.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home