sorting - Sort apps according to usage in android -
i has hashmap of apps usage. in details,a list of apps
//apps<resolveinfo> list<resolveinfo> pkgappslist = new arraylist<resolveinfo>(); packagemanager pm = this.getpackagemanager(); pkgappslist = pm.queryintentactivities(mainintent, 0); and hashmap of popularity package name key string , usage integer(number of user clicks on each app).
//hashmap<string,integer> public static hashmap listpopularity = new hashmap<string, integer>(); listpopularity.put("com.example.app1",23) listpopularity.put("com.example.app2",11) what best approach sort apps list according package usages in hashmap. there may apps not in hashmap usage because of user not clicked on app
you need use comparable sort list....
a piece of code :
public class yourdatamodel implements comparable<yourdatamodel> { @override public int compareto(yourdatamodel o) { if (this.status.equals(o.status)) { return this.name.compareto(o.name); } else { return this.status.compareto(o.status); } } } have here idea implement comparable
Comments
Post a Comment