title: How to get permissions of an installed app
body: <p>Please help... i'm new to android development...i have search about my problem but didn't get any solution...
  i have also tried:
  <a href="https://stackoverflow.com/questions/5385957/how-to-get-apps-permission-for-each-app-how-to-do-it-programmatically-on-andro">Didn't understand it</a></p>
  
  <p>I have get a list of all installed apps so now i want show all the permissions of each application in a textview when click on it </p>
  
  <p><strong><em>List of all installed apps:</em></strong></p>
  
  <p><strong>Main Activity:</strong></p>
  
  <pre><code>public class MainActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      ListView userInstalledApps = (ListView)findViewById(R.id.installed_app_list);
  
      List&lt;AppList&gt; installedApps = getInstalledApps();
      AppAdapter installedAppAdapter = new AppAdapter(MainActivity.this, installedApps);
      userInstalledApps.setAdapter(installedAppAdapter);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  private List&lt;AppList&gt; getInstalledApps() {
      List&lt;AppList&gt; res = new ArrayList&lt;AppList&gt;();
      List&lt;PackageInfo&gt; packs = getPackageManager().getInstalledPackages(0);
      for (int i = 0; i &lt; packs.size(); i++) {
          PackageInfo p = packs.get(i);
          if ((isSystemPackage(p) == false)) {
              String appName = p.applicationInfo.loadLabel(getPackageManager()).toString();
              Drawable icon = p.applicationInfo.loadIcon(getPackageManager());
              res.add(new AppList(appName, icon));
          }
      }
      return res;
  }
  
  private boolean isSystemPackage(PackageInfo pkgInfo) {
      return ((pkgInfo.applicationInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM) != 0) ? true : false;
  }
  
  
  }
  </code></pre>
  
  <p><strong>AppList Class:</strong></p>
  
  <pre><code> public class AppList {
  
  private String name;
  Drawable icon;
  
  public AppList(String name, Drawable icon) {
      this.name = name;
      this.icon = icon;
  }
  
  public String getName() {
      return name;
  }
  
  public Drawable getIcon() {
      return icon;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>AppAdapter:</strong></p>
  
  <pre><code>public class AppAdapter extends BaseAdapter {
  
  private LayoutInflater layoutInflater;
  private List&lt;AppList&gt; listStorage;
  
  public AppAdapter(Context context, List&lt;AppList&gt; customizedListView) {
      layoutInflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      listStorage = customizedListView;
  }
  
  @Override
  public int getCount() {
      return listStorage.size();
  }
  
  @Override
  public Object getItem(int position) {
      return position;
  }
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
      ViewHolder listViewHolder;
      if(convertView == null){
          listViewHolder = new ViewHolder();
          convertView = layoutInflater.inflate(R.layout.installed_app_list, parent, false);
  
          listViewHolder.textInListView = (TextView)convertView.findViewById(R.id.list_app_name);
          listViewHolder.imageInListView = (ImageView)convertView.findViewById(R.id.app_icon);
          convertView.setTag(listViewHolder);
      }else{
          listViewHolder = (ViewHolder)convertView.getTag();
      }
      listViewHolder.textInListView.setText(listStorage.get(position).getName());
      listViewHolder.imageInListView.setImageDrawable(listStorage.get(position).getIcon());
  
      return convertView;
  }
  
  static class ViewHolder{
  
      TextView textInListView;
      ImageView imageInListView;
  }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#eceaea"&gt;
  
  &lt;ListView
      android:id="@+id/installed_app_list"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_alignParentTop="true"
      android:scrollbars="none" /&gt;
  
    &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>installed_apps_list.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;ImageView
      android:id="@+id/app_icon"
      android:layout_width="48dp"
      android:layout_height="48dp"
      android:contentDescription="@string/hello_world"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:layout_marginLeft="16dp"
      android:layout_marginTop="16dp"
      android:paddingBottom="8dp"/&gt;
  
  &lt;TextView
      android:id="@+id/list_app_name"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textStyle="bold"
      android:textSize="16dp"
      android:textColor="#000000"
      android:layout_toRightOf="@+id/app_icon"
      android:layout_alignTop="@+id/app_icon"
      android:layout_marginLeft="16dp"
      android:layout_marginTop="2dp"
      android:text="@string/hello_world"/&gt;
  
    &lt;/RelativeLayout&gt;
  </code></pre>
  
  <blockquote>
    <p>This is what i have done....i mean i get all the installed apps now i
    want each app permissions when click on any listed app....</p>
  </blockquote>