搜尋所有Android內的APP package name

尋找整台機器裡面的所有App的Package名稱的方法:




int flags = PackageManager.GET_META_DATA | PackageManager.GET_SHARED_LIBRARY_FILES | PackageManager.GET_UNINSTALLED_PACKAGES; 
PackageManager pm = getPackageManager(); 
final List packs = pm.getInstalledApplications(flags);
 for (ApplicationInfo appinfo : packs) {
   if ((appinfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
   //system application
   } else {
   //installed by user
   }
 }

留言

這個網誌中的熱門文章

利用Accuweather實作天氣APP

實作Android導覽教學(fragment)