I want to write the code on how to unlock the Android Phone programmatically.
I want lock or unlock the phone when the user taps the proximity sensor.
public class MyActivity extends Activity{
private static final String ACTION = "android.intent.action.ACTION_SCREEN_OFF";
BroadcastReceiver myReceiver;
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
context = this;
final IntentFilter theFilter = new IntentFilter();
theFilter.addAction(ACTION);
context.registerReceiver(myReceiver, theFilter);
System.out.println("inside increate");
myReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
System.out.println("phone locked*****");
}
};
}}