我的代码是:
Intent lockintent = new Intent();
lockintent.setClassName("com.example.lalitha.s1",
"com.example.lalitha.s1.WipeActivity");
context.startActivity(lockintent);
mDPM = DevicePolicyManager)context.getSystemService( Context.DEVICE_POLICY_SERVICE);
mDeviceAdmin = new ComponentName(context, DeviceAdminSample .class);
boolean active = mDPM.isAdminActive(mDeviceAdmin);
if (active) {
mDPM.lockNow();
}
else{
Toast.makeText(context, "not locked", Toast.LENGTH_LONG).show();
}
context.startActivity
未执行
如果我省略那么它的显示设备"没有锁定"
答案 0 :(得分:0)
替换此位:
Intent lockintent = new Intent();
lockintent.setClassName("com.example.lalitha.s1",
"com.example.lalitha.s1.WipeActivity");
与
Intent lockintent = new Intent(context, WipeActivity.class);
lockintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
但请记住,Toast消息仍将显示。