我想開發一個Android應用程序,我有以下要求。有沒有辦法通過代碼,我可以在調試模式下獲取設備上安裝的應用程序列表。Android - 在調試模式下獲取應用程序列表
在此先感謝。
編輯 - 我試了下面的代碼。
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
}
}
}
請定義「在調試模式下」。 – CommonsWare
在android manifest xml中,如果android debuggable屬性設置爲true,那麼該應用程序將設置爲android調試模式。 – Prem