title: Autoclose window popup after some time span. How to do
body: <p>I am trying to autoclose my inflated popup window after some seconds with some time counter. I have not idea ho to do with count timer ( 5 seconds ).</p>
  
  <pre><code>  LayoutInflater inflater = (LayoutInflater)screen.getSystemService(screen.LAYOUT_INFLATER_SERVICE);
                      layout =  inflater.inflate(R.layout.log_viewer,null);
  
                      AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                      builder.setCancelable(true);
                      builder.setView(layout);
  
                      AlertDialog alertDialog = builder.create(); 
                      alertDialog.show();
  
                      Button btn0= (Button)layout.findViewById(R.id.btn0);
                      Button btn1= (Button)layout.findViewById(R.id.btn1);
                      Button btn2= (Button)layout.findViewById(R.id.btn2);
                      btn0.setOnClickListener(new OnClickListener() {
  
                          @Override
                          public void onClick(View v) {
  
                              Intent i =new Intent(Main_Activity.this,Act.class);
                              startActivity(i);
                              overridePendingTransition(R.anim.animation,R.anim.animation2);
                          }
                      });  
                      btn1.setOnClickListener(new OnClickListener() {
  
                          @Override
                          public void onClick(View v) {
  
                              Intent i =new Intent(Main_Activity.this,Activity2.class);
                              startActivity(i);
                              overridePendingTransition(R.anim.animation,R.anim.animation2);
                          }
                      });  
                      btn2.setOnClickListener(new OnClickListener() {
  
                          @Override
                          public void onClick(View v) {
  
                              Intent i =new Intent(Main_Activity.this,Activity1.class);
                              startActivity(i);
                              overridePendingTransition(R.anim.animation,R.anim.animation2);
                          }
                      });  
  
  
                      WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
                      Window window = alertDialog.getWindow();
                      lp.copyFrom(window.getAttributes());
  
                      lp.width = WindowManager.LayoutParams.MATCH_PARENT;
                      lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
                      window.setAttributes(lp);
  </code></pre>