gpt4 book ai didi

java - 当有一定数量的密码尝试失败时让 Android 手机重启的语言

转载 作者:行者123 更新时间:2023-11-30 01:15:43 26 4
gpt4 key购买 nike

当出现一定数量的屏幕密码失败时,我正在尝试让 Android 手机 (LP 5.1.1) 重新启动。这是我在 Keyguard 中的语言:

if (mLockPatternUtils.isSeparateEncryptionPasswordEnabled() && failedAttempts >= 5) {
final PowerManager powerManager = mContext.getSystemService(PowerManager.class);
powerManager.reboot(null);

编译错误:

frameworks/base/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java:409: 

错误:类 Context 中的方法 getSystemService 不能应用于给定类型;最终 PowerManager powerManager = mContext.getSystemService(PowerManager.class); ^必填:字符串

找到:类

原因:实参Class无法转换为

字符串通过方法调用转换

有什么想法吗?提前致谢

最佳答案

我不使用 PowerManager.class,而是使用 Context.POWER_SERVICE

或者可能只是:

    if (mLockPatternUtils.isSeparateEncryptionPasswordEnabled() &&vfailedAttempts >= 5) { 
final PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
powerManager.reboot(null);
}

您必须将 Context 添加到导入中。

当然,如果您的目标手机是 ROOTED:

Runtime.getRuntime().exec(new String[]{"/system/bin/su","-c","reboot now"});

就足够了。

关于java - 当有一定数量的密码尝试失败时让 Android 手机重启的语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37891671/

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