In android, how does one change the main menu icon to the installation time?
1. Add the following code to LauncherModel. java. If it is KK Launcher3 ApplicationInfo, replace it with AppInfo.
Public static final Comparator <ApplicationInfo> getInstallTimeComparator (){
Return new Comparator <ApplicationInfo> (){
Public final int compare (ApplicationInfo a, ApplicationInfo B ){
Return a. firstInstallTime = B. firstInstallTime? 0: a. firstInstallTime> B. firstInstallTime? 1:-1;
}
};
}
Public static class InstallTimeComparator implements Comparator <ResolveInfo> {
Private PackageManager mPackageManager;
List <ResolveInfo> mapps;
InstallTimeComparator (PackageManager pm, List <ResolveInfo> apps)
{
MPackageManager = pm;
Mapps = apps;
}
Public final int compare (ResolveInfo a, ResolveInfo B ){
String packageNameA = a. activityInfo. applicationInfo. packageName;
String packageNameB = B. activityInfo. applicationInfo. packageName;
Long firstInstallTimeA = 0, firstInstallTimeB = 0;
Try {
FirstInstallTimeA = mPackageManager. getPackageInfo (packageNameA, 0). firstInstallTime;
FirstInstallTimeB = mPackageManager. getPackageInfo (packageNameB, 0). firstInstallTime;
} Catch (Exception e ){
E. printStackTrace ();
Return 0;
}
Return firstInstallTimeA = firstInstallTimeB? 0: firstInstallTimeA> firstInstallTimeB? 1:-1;
}
};
2. Modify the loadall1_bybatch () method of LauncherModel. java:
Set
Collections. sort (apps, new LauncherModel. ShortcutNameComparator (packageManager, mLabelCache ));
Replace:
Collections. sort (apps, new InstallTimeComparator (packageManager, apps ));
3. Modify the setApps method of AppsCustomizePagedview. java.
Set
Collections. sort (mApps, LauncherModel. getAppNameComparator ());
Replace:
Collections. sort (mApps, LauncherModel. getInstallTimeComparator ());
4. The reorderApps method is called for system sorting. Therefore, you must sort the installation time in other conditions. Please add the reorderApps method before calling it.
Collections. sort (mApps, LauncherModel. getInstallTimeComparator ());
For example, if you want to install a new sorting method after installing an application, you need to add the sort call before the addApps method of AppsCustomizePagedview. java.
There are too many app icons in the main menu of Android. How can I classify them into a folder?
1. Press the blank button on the desktop to display the "select activity" window. Select "folder". The first item is to create a folder.
2. Now you can put the icon in this file. The operation is similar to deleting the icon on the desktop.
3. Open the folder icon and you will be able to see the applications you just added.
4. Click the title of the opened folder to change the folder name.
By the way, we recommend that you develop the "80 sink calculator". I hope you will have a good time.
How to sort the android40 Main Menu
The default APP sorting for the preset desktop is not only good in res/xml/default_workspace.xml under Launcher2. Of course, you can also manually add it when LauncherProvider creates the database for the first time. In short, to sort, you only need to add some apps to the location you need to discharge, and then store the location coordinates (X, Y) into the database. You can see the source code.