<activity
android:name="com.itydl.lockscreen.Remove"
android:label="一键卸载" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
package com.itydl.lockscreen;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
public class Remove extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
//
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_remove);
}
public void remove(View v){
//调用卸载的界面,要去上层源码中看一下卸载界面的意图是什么。通过查看源码,如下:
/**
* <intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DELETE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
*/
//在卸载之前首先要取消设激活设备管理器
//获取设备管理器
DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
ComponentName who = new ComponentName(this,DeviceAdminSample.class);
dpm.removeActiveAdmin(who);//Remove a current administration component. This can only be called by the application that owns the administration component
//卸载,启动卸载界面
Intent remove = new Intent("android.intent.action.DELETE");
remove.addCategory("android.intent.category.DEFAULT");
remove.setData(Uri.parse("package:"+getPackageName()));//表示卸载本程序,Return the name of this application's package.
startActivity(remove);//卸载用户apk界面
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > --------------------这里一定修改。 <Button android:onClick="remove" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="一键卸载" /> </RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00000000"> ---------------------设置为透明色 </RelativeLayout>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dmp = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
lockScreen(null);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有