gpt4 book ai didi

Android - 在 Debug模式下获取应用程序列表

转载 作者:搜寻专家 更新时间:2023-11-01 09:02:06 25 4
gpt4 key购买 nike

我正在尝试开发一个 android 应用程序,我有以下要求。有没有办法通过代码,我可以在 Debug模式下获取设备上安装的应用程序列表。

提前致谢。

编辑 - 我尝试了以下代码。

 PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

for (int i=0; i < packages.size(); i++)
{
if ((packages.get(i).flags & ApplicationInfo.FLAG_SYSTEM) == 1)
{
//This is for System applications
}
else
{

boolean isDebuggable = (0 != ( getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE ) );

if((pm.getLaunchIntentForPackage(packages.get(i).packageName)!=null) && (isDebuggable = true) )
{
// Only For Apps with debug mode set true, this line should get executed
// But this does not happens
}
}
}

最佳答案

给你,

Intent main = new Intent(Intent.ACTION_MAIN, null);
main.addCategory(Intent.CATEGORY_LAUNCHER);
List pkgAppsList = context.getPackageManager().queryIntentActivities( main, 0);

这应该为您提供足够的信息以启动应用程序。

关于Android - 在 Debug模式下获取应用程序列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14381612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com