Android动态添加Device Admin权限
/**********************************************************************
* Android动态添加Device Admin权限
* 说明:
* Tony在Android 5上研究的怎么动态添加设备管理员权限。
*
* 2018-6-20 深圳 宝安西乡 曾剑锋
*********************************************************************/ private void enableDeviceAdmin() { ComponentName deviceAdmin = new ComponentName(this, AdminReceiver.class);
DevicePolicyManager mDpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); // First of all, to access anything you must be device owner
if (mDpm.isDeviceOwnerApp(getPackageName())) { // If not device admin, ask to become one
if (!mDpm.isAdminActive(deviceAdmin) &&
mDpm.isDeviceOwnerApp(getPackageName())) { Log.v(TAG, "Not device admin. Asking device owner to become one."); Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdmin);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"You need to be a device admin to enable device admin."); startActivity(intent);
} // Device owner and admin : enter device admin
else {
mDpm.setLockTaskPackages(deviceAdmin, new String[]{
getPackageName(), /* PUT OTHER PACKAGE NAMES HERE! /
});
startLockTask();
}
} // Not device owner - can't access anything
else {
Log.v(TAG, "Not device owner");
Toast.makeText(this, "Not device owner", Toast.LENGTH_SHORT).show();
}
}
Android动态添加Device Admin权限的更多相关文章
- Android 动态添加Spinner(.java文件内实现) 实现 改变spinner 内文字属性
动态添加spinner 控件 Spinner s = new Spinner(this); String []items={"自己定义的要显示的数组"}; my_SpinnerAd ...
- Android动态添加和移除布局
package com.hyang.administrator.studentproject; import android.os.Bundle; import android.support.v7. ...
- android动态添加TextView或者ImageView
动态添加 text1=new TextView(this); text1.setText("动态添加"); ((LinearLayout) this.findViewById(R. ...
- Android -- 动态添加布局
在做项目的时候,遇到了scrollView与listView结合的使用,导致了滑动的混乱,但是有一个办法可以解决掉这个问题,就是手写listView的高度,还有另外一种方法,传送门:<Andro ...
- Android动态添加碎片
我们编写一个能够用过按钮动态更替碎片的APP,首先在主页上显示第一个碎片,点击按钮后可以替换到第二个碎片,或者删除已经替换掉的第二个碎片. 一.MainActivity.java import and ...
- Android 动态添加删除ExpandableListView的item的例子
这个例子可以学习到如下几点: 1.通过自定义Dialog(单独布局的xml文件进行弹出显示) 2.通过menu点击监听添加,删除view中的items 3.点击ExpandableListView中g ...
- 关于动态添加iview admin路由以及刷新侧边栏
在main.js中的mounted中使用router.addRouters()方法后界面上的路由并未刷新. 在注释掉路由跳转的权限限制之后,发现直接在地址栏输入对应路由能够进去,只是侧边栏没有刷新. ...
- Android动态添加布局
//1.利用LayoutInflater的inflate动态加载XML mLinearLayout = (LinearLayout)findViewById(R.id.LinearLayout_ID) ...
- Android — — —动态添加碎片
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=" ...
随机推荐
- zzw原创_根据某一文件复制出大量固定位数后缀名的递增的文件
1.trre.sh :根据某一文件复制出大量固定位数后后缀递增的文件. 如将 SPINFO_190516_20170109.001 复制成SPINFO_190516_20170109.002 ...
- Python内置模块之time、random、hashlib、OS、sys、UUID模块
Python常用模块 1.time模块 在Python中,通常有这三种方式来表示时间:时间戳.元组(struct_time).格式化的时间字符串: (1)时间戳(timestamp) :通常来说,时间 ...
- ajax请求成功前,加载中loading显示
/*第一次刷新--非定时器刷新数据*/ var fistInitColumn = true; var getAllColumnDatas = function(){ var params = {}; ...
- PyQt+Html+Js
先做记录,后面有时间在仔细研究 https://www.cnblogs.com/jiangjh5/p/7209315.html?utm_source=itdadao&utm_medium=re ...
- mp4、AAC数据格式、解析文件的创建修改时间
AAC文件 资料: http://blog.csdn.net/u013427969/article/details/53091594 http://blog.chinaunix.net/uid-260 ...
- UVA 11990 `Dynamic'' Inversion CDQ分治, 归并排序, 树状数组, 尺取法, 三偏序统计 难度: 2
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- POJ 3080 Blue Jeans 后缀数组, 高度数组 难度:1
题目 http://poj.org/problem?id=3080 题意 有m个(2<=m<=10)不包含空格的字符串,长度为60个字符,求所有字符串中都出现过的最长公共子序列,若该子序列 ...
- 设计一个高质量的API接口
参考网址:http://url.cn/5UaTeyv 前言 在设计接口时,有很多因素要考虑,如接口的业务定位,接口的安全性,接口的可扩展性.接口的稳定性.接口的跨域性.接口的协议规则.接口的路径规则. ...
- RabbitMQ 简单的消息发送与接收
RabbitMQ是建立在AMQP(Advanced Message Queuing Protocol,高级消息队列协议)基础上的,而AMQP是建立在TCP协议之上的. 因此,RabbitMQ是需要建立 ...
- C++标准异常概述
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...