Commit 6dcb33ce authored by Administrator's avatar Administrator

sort

parent 9d78c49e
......@@ -82,6 +82,7 @@ public class AppsActivity extends AppCompatActivity {
super.run();
//扫描得到APP列表
final List<MyAppInfo> appInfos = ApkTool.scanLocalInstallAppList(AppsActivity.this.getPackageManager(), isFilter);
mHandler.post(new Runnable() {
@Override
public void run() {
......
package top.littlerich.virtuallocation.model;
import android.graphics.drawable.Drawable;
/**
* Created by xuqingfu on 17/4/24.
*/
......@@ -9,14 +10,6 @@ public class MyAppInfo {
private String appName;
private String pkgName;
public MyAppInfo(Drawable image, String appName, String pkgName) {
this.image = image;
this.appName = appName;
this.pkgName = pkgName;
}
public MyAppInfo() {
}
public Drawable getImage() {
return image;
......
......@@ -6,6 +6,8 @@ import android.content.pm.PackageManager;
import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
......@@ -32,9 +34,9 @@ public class ApkTool {
continue;
}
MyAppInfo myAppInfo = new MyAppInfo();
myAppInfo.setPkgName(packageInfo.applicationInfo.loadLabel(packageManager).toString());
myAppInfo.setPkgName(packageInfo.packageName);
myAppInfo.setAppName(packageInfo.packageName);
myAppInfo.setAppName(packageInfo.applicationInfo.loadLabel(packageManager).toString());
if (packageInfo.applicationInfo.loadIcon(packageManager) == null) {
continue;
}
......@@ -52,6 +54,12 @@ public class ApkTool {
} catch (Exception e) {
Log.e(TAG, "===============获取应用包信息失败");
}
Collections.sort(myAppInfos, new Comparator<MyAppInfo>() {
@Override
public int compare(MyAppInfo o1, MyAppInfo o2) {
return o1.getAppName().compareTo(o2.getAppName());
}
});
return myAppInfos;
}
......
......@@ -35,7 +35,7 @@
>
<TextView
android:id="@+id/tv_app_pkg"
android:id="@+id/tv_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
......@@ -44,7 +44,7 @@
/>
<TextView
android:id="@+id/tv_app_name"
android:id="@+id/tv_app_pkg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment