开发者

How to find installed applications in Android?

I want to get the name and package name o开发者_高级运维f a third party application installed in Android. I have tried but I got the name of all applications (third party and pre installed).

How can I identify whether an application is a system application or an other application?


This will do the trick...cheers :)

PackageManager pm = getPackageManager();
List<PackageInfo> list = pm.getInstalledPackages(0);

for (PackageInfo pi : list) {
   ApplicationInfo ai;
   try {
      ai = pm.getApplicationInfo(pi.packageName, 0);
      System.out.println(">>>>>>packages is<<<<<<<<" + ai.publicSourceDir);

      // this condition if satisfied means the application currently refered by ai
      // variable is
      // a system application
      if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
         Log.d(getClass().getSimpleName(), ">>>>>>packages is system package" + pi.packageName);
       }
    } catch (NameNotFoundException e) {
        Log.d(getClass().getSimpleName(), "Name not found", e);
    }
}


Goto DDMS Perspective ---> Click on the Emulator or Device ---> Check File Explorer ---> data --> data folder ---> there will be app names installed, note their package name :)

Hope it helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜