Solution for the above issue, we can dismiss the progress dialog before finish the activity.
Issue :
Activity com.sample.ViewLeakIssueActivity has leaked window com.android.internal.policy.impl.TvWindow$DecorView@6bc30788 that was originally added here
E/WindowManager( 1687): at android.view.ViewRoot.
E/WindowManager( 1687): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
-----
Sample Leak Issue
public class ViewLeakIssueActivity extends Activity {
volatile ProgressDialog pd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
pd = ProgressDialog.show(ViewLeakIssueActivity.this, "", "test...", true);
new Thread() {
public void run() {
try {
sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("@@@@@@@@@@@"+ViewLeakIssueActivity.this+pd.isShowing());
pd.dismiss();
}
}.start();
finish();
}
}
Solution for the above issue, we can dismiss the progress dialog before finish the activity.
@Override
public void finish() {
if(pd.isShowing()){
pd.dismiss();
}
super.finish();
}
When I google for WindowLeaked exception, I always read about creating dialogs in async tasks, but there's way more simple scenario that causes the issue - opening the dialog in the main UI thread and rotating the device while it's still open. Do I have to keep track of all the open dialogs to call dismiss() in Activity.onStop()?
ReplyDeleteYou are explanation is excellent and nice posting thanks for sharing this in formation can you give me the over view on Android Development.
ReplyDeleteGreat Explainationation, I like this blog.
ReplyDeleteYour application should get an ANR error
ReplyDeletesaved my day,,,,,
ReplyDelete⭐ Data Analytics Classes Online
ReplyDeleteChoose professional data analytics classes online for flexible learning.
The syllabus includes reporting and visualization techniques.
Practical tasks improve your hands-on experience.
Live sessions keep learning engaging.
Trainer support is available throughout the course.
It helps you build a strong analytics career.
Enroll in salesforce developer course
ReplyDeleteto master Apex, Visualforce, and Lightning components, preparing you for real-world CRM development. Gain hands-on experience and boost your career as a certified Salesforce developer.
Boost your career with salesforce developer training
ReplyDeletegaining hands-on experience in Apex, Visualforce, and Lightning components. Enhance your skills to design, build, and deploy customized Salesforce solutions efficiently.
Unlock your data skills with power bi classes online
ReplyDeletedesigned to teach interactive dashboards, data modeling, and visualization techniques. Learn at your own pace and become proficient in transforming raw data into actionable insights.
Informative post! Learn data modeling training courses
ReplyDeleteto turn business requirements into effective and professional database structures.
Learn Python online with step-by-step coding demonstrations. It simplifies complex topics. This learn python online enhances understanding. It includes exercises. Learners gain practical knowledge. It is beginner friendly.
ReplyDelete