Hello All,
               I am very new to Android, and this is my first program.
I am trying to create an activity with a button which will lock the
screen of the device. It will just be a normal lock which the user can
swipe and remove.
I do not understand why even after complete execution of the program
it is not working. Please help.

My code is as follows:

package com.droid.ScreenLock;

import android.app.Activity;
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {
        private KeyguardManager n;
        private Boolean b;
        private KeyguardLock l;

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                Button tbut = (Button) findViewById(R.id.button1);
                tbut.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View arg0) {
                                // TODO Auto-generated method stub
                                n = (KeyguardManager) 
getSystemService(KEYGUARD_SERVICE);
                                b = n.inKeyguardRestrictedInputMode();
                        }
                });
        }

        public void onPause() {
                super.onPause();
                if (b != true) {
                        l = (KeyguardLock) n.newKeyguardLock("User");
                        l.reenableKeyguard();
                        l = null;
                }
        }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to