gpt4 book ai didi

android - 用户调用电话号码后锁定 Android 手机

转载 作者:IT老高 更新时间:2023-10-28 23:25:42 26 4
gpt4 key购买 nike

我正在开发一个安全应用程序,如果用户调用一个不经常调用的电话号码并且他以前从未调用过电话,则该用户将不得不重新验证自己的身份。为此,我想在检查电话号码后锁定手机。

public class outgoingCalls extends BroadcastReceiver {

public void onReceive(Context context, Intent intent) {

Log.v("onReceive", "In onReceive()");
if (confidence == 0) {
Log.v("onReceive","confidence zeroed");
Intent i = new Intent();
i.setClassName("abc.xyz.SECURITY","abc.xyz.SECURITY.lockActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}

在这个新的Activity lockActivity中,我需要锁定我评论过的手机//LOCK PHONE

public class lockActivity extends Activity {  

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v("lock","lockActivity onCreate method called");
// setContentView(R.layout.main);
Log.v("lock","locking");
// LOCK PHONE
}
}

手机没有被我尝试过的方法锁定。其中包括:

1.  KeyguardManager mgr = (KeyguardManager)   getSystemService(Activity.KEYGUARD_SERVICE); 
KeyguardLock lock = mgr.newKeyguardLock("edu.Boston.SECURITY.lockActivity");
((KeyguardLock) lock).reenableKeyguard();

2. PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);
manager.goToSleep(100);//int amountOfTime

3. PowerManager.WakeLock wl = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Tag");
wl.acquire();
wl.release();

4. WindowManager.LayoutParams params = getWindow().getAttributes();
params.screenBrightness = 0;
getWindow().setAttributes(params);

Android list 文件具有以下权限

    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />

为什么我无法锁定手机?任何指针?非常感谢您的帮助。欣赏!

最佳答案

尝试创建一个 DevicePolicyManager

http://developer.android.com/training/enterprise/device-management-policy.html

然后调用:

DevicePolicyManager mDPM  = (DevicePolicyManager)context.getSystemService(Context.DEVICE_POLICY_SERVICE);
mDPM.lockNow();

关于android - 用户调用电话号码后锁定 Android 手机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13062349/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com