Button Click event not performed
<p>I have write the following code in the onCreate() method of Activity class</p>

<pre><code>Button btn=(Button)findViewById(R.id.button1);
        btn.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v) 
            {
                WindowManager.LayoutParams params = getWindow().getAttributes();
                params.screenBrightness = 0;
                getWindow().setAttributes(params);
                Toast.makeText(v.getContext(),"Button Clicked",Toast.LENGTH_LONG).show();
            }
        });
        btn.performClick();
</code></pre>

<p>But the problem is that the action on the button click is not happened, but if I click on that button then this action is performed.</p>

<p>I want to lock the screen by using that code, but it locks after the full execution of onCreate() method,</p>

<p>Any guess how i can do this.</p>
