过滤不包含启动界面的系统app

本文介绍了通过桌面启动属性Intent.CATEGORY_LAUNCHER获取没有启动界面的app的方法,并给出了具体函数。还展示了在三星S7和小米8上的测试结果,包括系统app列表及不能卸载的app,结论是可获取只在桌面有图标的系统app。

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

获取没有启动界面的app 通过桌面启动属性Intent.CATEGORY_LAUNCHER获取,具体函数如下:

 

public void getInstalledSystemApp() {

try {

PackageManager packageManager = getPackageManager();

Intent intent = new Intent(Intent.ACTION_MAIN, null);

intent.addCategory(Intent.CATEGORY_LAUNCHER);

 

List<ResolveInfo> packageInfos = packageManager.queryIntentActivities(intent, 0);

 

for (int i = 0; i < packageInfos.size(); i++) {

ResolveInfo packageInfo = packageInfos.get(i);

 

String packageName = packageInfo.activityInfo.packageName;

if((ApplicationInfo.FLAG_SYSTEM & packageInfo.activityInfo.applicationInfo.flags) != 0){

String appLabelString = packageInfo.activityInfo.applicationInfo.loadLabel(packageManager).toString();

Log.e("appappinfo", i + " -- packageName: " + packageName +" appLabelString "+appLabelString);

}

 

}

} catch (Exception e) {

Log.e("get app ", "获取应用包信息失败");

}

 

}

 

获取测试结果:

1.三星s7的系统app

0 -- packageName: com.sec.android.gallery3d appLabelString 相册

1 -- packageName: com.android.chrome appLabelString Chrome

2 -- packageName: com.android.settings appLabelString 设置

3 -- packageName: com.android.vending appLabelString Google Play 商店

4 -- packageName: com.google.android.apps.docs appLabelString 云端硬盘

5 -- packageName: com.google.android.apps.maps appLabelString 地图

6 -- packageName: com.google.android.apps.photos appLabelString 相册

7 -- packageName: com.google.android.gm appLabelString Gmail

8 -- packageName: com.google.android.music appLabelString Google Play 音乐

9 -- packageName: com.google.android.talk appLabelString 环聊

10 -- packageName: com.google.android.youtube appLabelString YouTube

11 -- packageName: com.samsung.android.calendar appLabelString 日历

12 -- packageName: com.samsung.android.contacts appLabelString 联系人

13 -- packageName: com.samsung.android.contacts appLabelString 联系人

14 -- packageName: com.samsung.android.email.provider appLabelString 电子邮件

15 -- packageName: com.samsung.android.messaging appLabelString 信息

16 -- packageName: com.sec.android.app.camera appLabelString 相机

17 -- packageName: com.sec.android.app.sbrowser appLabelString 三星浏览器

18 -- packageName: com.sec.android.app.shealth appLabelString 三星健康

21 -- packageName: com.facebook.katana appLabelString Facebook

22 -- packageName: com.google.android.googlequicksearchbox appLabelString Google

23 -- packageName: com.instagram.android appLabelString Instagram

24 -- packageName: com.microsoft.office.excel appLabelString Excel

25 -- packageName: com.microsoft.office.powerpoint appLabelString PowerPoint

26 -- packageName: com.microsoft.office.word appLabelString Word

27 -- packageName: com.microsoft.skydrive appLabelString OneDrive

28 -- packageName: com.samsung.android.app.memo appLabelString 备忘录

29 -- packageName: com.samsung.android.app.watchmanager appLabelString Samsung Gear

30 -- packageName: com.samsung.android.game.gamehome appLabelString 游戏中心

31 -- packageName: com.samsung.android.lool appLabelString 设备维护

32 -- packageName: com.samsung.android.spay appLabelString Samsung Pay

33 -- packageName: com.samsung.android.themestore appLabelString 主题商店

34 -- packageName: com.samsung.android.voc appLabelString 盖乐世空间

35 -- packageName: com.samsung.voiceserviceplatform appLabelString S Voice

36 -- packageName: com.sec.android.app.clockpackage appLabelString 时钟

37 -- packageName: com.sec.android.app.myfiles appLabelString 我的文件

38 -- packageName: com.sec.android.app.popupcalculator appLabelString 计算器

39 -- packageName: com.sec.android.app.samsungapps appLabelString 应用商店

40 -- packageName: com.sec.android.app.voicenote appLabelString 录音机

41 -- packageName: com.skype.raider appLabelString Skype

42 -- packageName: com.whatsapp appLabelString WhatsApp

 

s7共有系统app41个,获取的app列表也有41个,其中app名字为“联系人”的有两个,设备上有“电话”这个程序没有显示在上面列表里面,电话属于联系人app的一项。

 

2.小米8的系统app:

0 -- packageName: com.android.browser appLabelString 浏览器

1 -- packageName: com.android.calendar appLabelString 日历

2 -- packageName: com.android.camera appLabelString 相机

3 -- packageName: com.android.contacts appLabelString 通讯录与拨号

4 -- packageName: com.android.contacts appLabelString 通讯录与拨号

5 -- packageName: com.android.deskclock appLabelString 时钟

6 -- packageName: com.android.fileexplorer appLabelString 文件管理

7 -- packageName: com.android.mms appLabelString 短信

8 -- packageName: com.android.settings appLabelString 设置

9 -- packageName: com.android.soundrecorder appLabelString 录音机

10 -- packageName: com.android.thememanager appLabelString 主题壁纸

11 -- packageName: com.mipay.wallet appLabelString 钱包

12 -- packageName: com.miui.gallery appLabelString 相册

13 -- packageName: com.miui.miservice appLabelString 服务与反馈

14 -- packageName: com.xiaomi.market appLabelString 应用商店

15 -- packageName: com.android.providers.downloads.ui appLabelString 下载管理

16 -- packageName: com.android.stk appLabelString USIM卡应用

17 -- packageName: com.miui.player appLabelString 音乐

18 -- packageName: com.miui.securitycenter appLabelString 手机管家

19 -- packageName: com.miui.video appLabelString 小米视频

20 -- packageName: com.miui.voiceassist appLabelString 小爱同学

 

手机上不能卸载的app有 时钟/录音机/下载管理/小爱同学/USIM卡应用/主题壁纸/应用商店/文件管理/钱包/小米视频/音乐/服务与反馈/日历/联系人/电话/短信/浏览器/相机/手机管家/设置/相册/

都是21款,其中上面的列表有两项 通讯录与拨号,下面不能卸载 联系人/电话

 

结论:可以获取到 只在桌面上有图标的系统app(测试验证三星S7、小米8 结果正确)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值