package cn.itcast.lockscreen;
import android.app.Activity;
import android.app.KeyguardManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
/**
* device admin : ��ȡ�豸�ij�������ԱȨ��
*
* @author zehua
*
*/
public class LockscreenActivity extends Activity implements OnClickListener {
private static final String LOCK_TAG = null;
private Button bt_lock;
private Button bt_wipe;
private Button bt_close;
private Button bt_uninstall;
DevicePolicyManager policyManager;
ComponentName componentName;
private final int requestCode = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bt_lock = (Button) this.findViewById(R.id.button1);
bt_wipe = (Button) this.findViewById(R.id.button2);
bt_close = (Button) this.findViewById(R.id.button3);
bt_uninstall = (Button) this.findViewById(R.id.button4);
bt_lock.setOnClickListener(this);
bt_wipe.setOnClickListener(this);
bt_close.setOnClickListener(this);
bt_uninstall.setOnClickListener(this);
policyManager = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
componentName = new ComponentName(this, MyAdmin.class);
if (!policyManager.isAdminActive(componentName)) {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName);
startActivity(intent);
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1: // 显示出要输入密码才能进入
policyManager.resetPassword("1234", 0);
policyManager.lockNow();
break;
case R.id.button2: // 清除数据
policyManager.wipeData(0);
break;
case R.id.button3: // 锁屏并关闭屏幕
systemLock();
break;
case R.id.button4: // 锁屏并关闭屏幕
UninstallActivity();
break;
}
}
/**
* 锁屏并关闭屏幕
*/
private void systemLock()
{
if (this.policyManager.isAdminActive(this.componentName))
{
Window localWindow = getWindow();
WindowManager.LayoutParams localLayoutParams = localWindow.getAttributes();
localLayoutParams.screenBrightness = 0.05F;
localWindow.setAttributes(localLayoutParams);
this.policyManager.lockNow();
}
finish();
}
/**
* 停用设备管理器并卸载程序
*/
private void UninstallActivity(){
this.policyManager.removeActiveAdmin(this.componentName);
startActivity(new Intent("android.intent.action.DELETE", Uri.parse("package:cn.itcast.lockscreen")));
finish();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
锁屏&九宫格锁屏&解锁 一键锁屏功能源码(程序源码).zip
共38个文件
class:11个
png:6个
xml:5个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 38 浏览量
2023-03-17
08:48:56
上传
评论
收藏 1.14MB ZIP 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
锁屏&九宫格锁屏&解锁 一键锁屏功能源码(程序源码).zip (38个子文件)
weberLockscreen
project.properties 360B
.classpath 475B
.settings
org.eclipse.jdt.core.prefs 177B
assets
src
cn
itcast
lockscreen
LockscreenActivity.java 3KB
MyAdmin.java 139B
res
drawable-mdpi
ic_launcher.png 3KB
drawable-xhdpi
drawable-ldpi
ic_launcher.png 2KB
xml
my_admin.xml 343B
values
strings.xml 186B
layout
main.xml 1KB
raw
ylzs.mp3 274KB
drawable-hdpi
ic_launcher.png 4KB
bin
classes
cn
itcast
lockscreen
R$xml.class 395B
MyAdmin.class 309B
R$string.class 433B
R$layout.class 400B
R$id.class 484B
BuildConfig.class 349B
R$attr.class 346B
R$drawable.class 413B
R$raw.class 391B
R.class 637B
LockscreenActivity.class 4KB
resources.ap_ 285KB
jarlist.cache 120B
res
crunch
drawable-mdpi
ic_launcher.png 2KB
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
classes.dex 7KB
weberLockscreen.apk 290KB
dexedLibs
annotations-c686c909b30423b724ccbabfb28ba2ea.jar 943B
AndroidManifest.xml 1011B
lockscreen.apk 290KB
proguard.cfg 1KB
.project 851B
AndroidManifest.xml 1011B
gen
cn
itcast
lockscreen
BuildConfig.java 162B
R.java 1KB
共 38 条
- 1
资源评论
金枝玉叶9
- 粉丝: 137
- 资源: 7640
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功