daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PackageInfo info = getPackageManager().getPackageArchiveInfo(andPath, 0);
  2. ApplicationInfo appinfo = info.applicationInfo;
  3. String packageName = getPackageManager().getApplicationLabel(appinfo).toString();
  4.  
  5. PackageManager pm=getPackageManager();
  6. ApplicationInfo ai;
  7. try {
  8.      ai = pm.getApplicationInfo(packageName, 0);
  9. } catch (final NameNotFoundException e) {
  10.      ai = null;
  11. }
  12.  
  13. final String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)");
  14.    
  15. CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName,PackageManager.GET_META_DATA));
  16.    
  17. public List<ApplicationInfo> getApplicationList(Context con){
  18.         PackageManager p = con.getPackageManager();
  19.         List<ApplicationInfo> info = p.getInstalledApplications(0);
  20.         return info;
  21.     }
  22.    
  23. public String applicationLabel(Context con,ApplicationInfo info){
  24.         PackageManager p = con.getPackageManager();
  25.         String label = p.getApplicationLabel(info).toString();
  26.         return label;
  27.     }
  28.    
  29. List<ApplicationInfo> info = new ArrayList<ApplicationInfo>();
  30.  
  31.         info = list.getApplicationList(this);
  32.         LinearLayout layout = (LinearLayout)findViewById(R.id.content);
  33.         layout.setOrientation(1);
  34.         int size = info.size();
  35.         Log.d("size",String.valueOf(size));
  36.         for(int i=0;i<size;i++){
  37.             Log.d("Val of I",String.valueOf(i));
  38.             String appname = list.applicationLabel(this,info.get(i)).toString();
  39.             Log.d("AppName",appname);
  40.             TextView tv = new TextView(this);
  41.             tv.setText(appname);
  42.             layout.addView(tv);
  43.         }
  44.  
  45.     }
  46.    
  47. public String applicationLabel (ApplicationInfo info){
  48.      PackageManager p = con.getPackageManager();
  49.      String label = p.getApplicationLabel(info).toString();
  50.      return label;
  51. }
  52.  
  53. I hope you got application info pass that application info to this function it will give application name.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top