我想編寫關於如何以編程方式解鎖Android手機的代碼。以編程方式解鎖Android手機?
我想在用戶點擊接近傳感器時鎖定或解鎖手機。
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*****");
}
};
}}
可能重複://計算器。 com/questions/3793221/how-my-app-can-unlock-screen-programatically) – razlebe