// Path: app/src/main/java/com/ervin/litepal/model/AppInfo.java
// public class AppInfo implements Comparable<Object>{
// 
//     private Drawable icon;
//     private String labelname;
//     private String packagename;
// 
//     public Drawable getIcon() {
//         return icon;
//     }
// 
//     public void setIcon(Drawable icon) {
//         this.icon = icon;
//     }
// 
//     public String getLabelname() {
//         return labelname;
//     }
// 
//     public void setLabelname(String labelname) {
//         this.labelname = labelname;
//     }
// 
//     public String getPackagename() {
//         return packagename;
//     }
// 
//     public void setPackagename(String packagename) {
//         this.packagename = packagename;
//     }
// 
//     @Override
//     public int compareTo(Object another) {
//         AppInfo f = (AppInfo)another;
//         return getLabelname().compareTo(f.getLabelname());
//     }
// }


import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import com.ervin.litepal.model.AppInfo;
import java.util.ArrayList;
import java.util.List;
package com.ervin.litepal.utils;




/**
 * Created by Ervin on 2016/3/2.
 */
public class AppinfoUtils {
    /**
     * 获取手机所有应用信息
     * @param context ：上下文
     */
    public static List<AppInfo> getAllAppInfo(Context context)
    {
        //TextView tv;
        List<AppInfo> appInfos = new ArrayList<AppInfo>();

        PackageManager pm =  context.getPackageManager();
        //Return a List of all packages that are installed on the device.
        List<PackageInfo> packageInfos = pm.getInstalledPackages(0); //获得所有已安装APP的包信息
        for(PackageInfo packageinfo : packageInfos )
        {
            AppInfo appInfo = new AppInfo();
            String packageName = packageinfo.packageName;  //包名
            Drawable icon = packageinfo.applicationInfo.loadIcon(pm);  //应用程序的icon
            String labelName = (String) packageinfo.applicationInfo.loadLabel(pm); //应用程序名称
            int flags = packageinfo.applicationInfo.flags;//点击看源码，表示应用的一些状态

            appInfo.setPackagename(packageName);
            appInfo.setIcon(icon);
            appInfo.setLabelname(labelName);

// Path: app/src/main/java/com/ervin/litepal/model/AppInfo.java
// public class AppInfo implements Comparable<Object>{
// 
//     private Drawable icon;
//     private String labelname;
//     private String packagename;
// 
//     public Drawable getIcon() {
//         return icon;
//     }
// 
//     public void setIcon(Drawable icon) {
//         this.icon = icon;
//     }
// 
//     public String getLabelname() {
//         return labelname;
//     }
// 
//     public void setLabelname(String labelname) {
//         this.labelname = labelname;
//     }
// 
//     public String getPackagename() {
//         return packagename;
//     }
// 
//     public void setPackagename(String packagename) {
//         this.packagename = packagename;
//     }
// 
//     @Override
//     public int compareTo(Object another) {
//         AppInfo f = (AppInfo)another;
//         return getLabelname().compareTo(f.getLabelname());
//     }
// }


// Path: app/src/main/java/com/ervin/litepal/utils/AppinfoUtils.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import com.ervin.litepal.model.AppInfo;
import java.util.ArrayList;
import java.util.List;

package com.ervin.litepal.utils;




/**
 * Created by Ervin on 2016/3/2.
 */
public class AppinfoUtils {
    /**
     * 获取手机所有应用信息
     * @param context ：上下文
     */
    public static List<AppInfo> getAllAppInfo(Context context)
    {
        //TextView tv;
        List<AppInfo> appInfos = new ArrayList<AppInfo>();

        PackageManager pm =  context.getPackageManager();
        //Return a List of all packages that are installed on the device.
        List<PackageInfo> packageInfos = pm.getInstalledPackages(0); //获得所有已安装APP的包信息
        for(PackageInfo packageinfo : packageInfos )
        {
            AppInfo appInfo = new AppInfo();
            String packageName = packageinfo.packageName;  //包名
            Drawable icon = packageinfo.applicationInfo.loadIcon(pm);  //应用程序的icon
            String labelName = (String) packageinfo.applicationInfo.loadLabel(pm); //应用程序名称
            int flags = packageinfo.applicationInfo.flags;//点击看源码，表示应用的一些状态

            appInfo.setPackagename(packageName);
            appInfo.setIcon(icon);
            appInfo.setLabelname(labelName);

            appInfos.add(appInfo);