当前位置:网站首页>Clear app data and get Icon
Clear app data and get Icon
2022-07-05 20:43:00 【Novice Xiaowang】
1. eliminate data
need Configure permissions
<uses-permission android:name="android.permission.ACCESS_INSTANT_APPS"/>
public static boolean clearData(String pkg){
Context context = HwContext.getContext();
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
am.clearApplicationUserData(pkg,null);
return true;
}perhaps
try {
Process exec = Runtime.getRuntime().exec("pm clear " + pkg);
exec.getInputStream().read(clearDataResult); To get the results
} catch (IOException e) {
e.printStackTrace();
}2. obtain app Icon
PackageManager pm = getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = pm.getPackageInfo(getPackageName(),0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
Drawable drawable = packageInfo.applicationInfo.loadIcon(pm);preservation icon
Drawable icon = t.getIcon();
File file = new File("icon.png");
try {
Bitmap bm = drawableToBitmap(icon);
FileOutputStream out = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
public Bitmap drawableToBitmap(Drawable drawable) {
Bitmap bitmap = Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
// canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}3. Simulate click events
public void constructClickEvent(int x,int y){
List<String> commands = new ArrayList<String>();
commands.add("input");
commands.add("tap");
commands.add("" + x);
commands.add("" + y);
try {
Process start = new ProcessBuilder(commands).start();
} catch (IOException e) {
e.printStackTrace();
}
}4. Simulate sliding events
public void constructSlideEvent(int x,int y,int newX,int newY){
InputStream is = null;
ByteArrayOutputStream baos = null;
List<String> commands = new ArrayList<String>();
commands.add("input");
commands.add("swipe");
commands.add("" + x);
commands.add("" + y);
commands.add("" + newX);
commands.add("" + newY);
ProcessBuilder pb = new ProcessBuilder(commands);
try {
Process prs = pb.start();
} catch (IOException e) {
e.printStackTrace();
}
}边栏推荐
- CVPR 2022 | 常见3D损坏和数据增强
- Duchefa low melting point agarose PPC Chinese and English instructions
- 19 mongoose modularization
- [UE4] unrealinsight obtains the real machine performance test report
- 小程序全局配置
- mongodb基操的练习
- Norgen AAV提取剂盒说明书(含特色)
- 小程序项目结构
- Monorepo管理方法论和依赖安全
- Is the securities account given by the school of Finance and business safe? Can I open an account?
猜你喜欢

解析五育融合之下的steam教育模式

Abnova CRISPR spcas9 polyclonal antibody protocol

Abnova e (diii) (WNV) recombinant protein Chinese and English instructions

PHP反序列化+MD5碰撞

线程池的使用

Welcome to the game and win rich bonuses: Code Golf Challenge officially launched

2.8 basic knowledge of project management process

1. Strengthen learning basic knowledge points

Abnova blood total nucleic acid purification kit pre installed relevant instructions

Abbkine丨TraKine F-actin染色试剂盒(绿色荧光)方案
随机推荐
Abnova e (diii) (WNV) recombinant protein Chinese and English instructions
3.3、项目评估
【UE4】UnrealInsight获取真机性能测试报告
Usaco3.4 "broken Gong rock" band raucous rockers - DP
Document method
Is it safe to open an account online? Where can I get a low commission?
Duchefa丨低熔点琼脂糖 PPC中英文说明书
CADD course learning (7) -- Simulation of target and small molecule interaction (semi flexible docking autodock)
Rainbow 5.7.1 supports docking with multiple public clouds and clusters for abnormal alarms
Welcome to the game and win rich bonuses: Code Golf Challenge officially launched
渗透创客精神文化转化的创客教育
清除app data以及获取图标
Make Jar, Not War
Abnova maxpab mouse derived polyclonal antibody solution
Norgen AAV提取剂盒说明书(含特色)
常用的视图容器类组件
Minimum commission for stock trading account opening, where to open an account with low commission? Is it safe to open an account on your mobile phone
CTF逆向基础
How to form standard interface documents
物联网智能家居基本方法实现之经典