26、高级工具--在设置中心中启用程序锁服务

在设置中心中实现程序锁服务的开启与关闭,通过点击操作启动UC浏览器并弹出密码输入框,确保应用的安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在设置中心中添加代码:

    //程序锁设置
    private View rl_setting_applocker;
    private TextView tv_setting_applocker_status;
    private CheckBox cb_setting_applocker;

//程序锁设置
        rl_setting_applocker = findViewById(R.id.rl_setting_applocker);
        tv_setting_applocker_status = (TextView)findViewById(R.id.tv_setting_applocker_status);
        cb_setting_applocker = (CheckBox)findViewById(R.id.cb_setting_applocker);
        boolean applock = sp.getBoolean("applock", false);
        cb_setting_applocker.setChecked(applock);
        tv_setting_applocker_status.setText(applock?"程序锁服务已经开启":"程序锁服务没有开启");
        tv_setting_applocker_status.setTextColor(applock ? Color.WHITE : Color.GRAY);
        rl_setting_applocker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SettingCenterActivity.this, WatchDogService.class);
                boolean b = !cb_setting_applocker.isChecked();
                if (b) {
                    startService(intent);
                }else {
                    stopService(intent);
                }
                cb_setting_applocker.setChecked(b);
                tv_setting_applocker_status.setText(b?"程序锁服务已经开启":"程序锁服务没有开启");
                tv_setting_applocker_status.setTextColor(b ? Color.WHITE : Color.GRAY);
                SharedPreferences.Editor editor = sp.edit();
                editor.putBoolean("applock", b);
                editor.commit();
            }
        });

在设置中心启动程序锁服务后,在程序锁界面对UC浏览器锁定,然后启动UC浏览器,弹出密码输入框:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

asmcvc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值