Reprint Please specify source: http://blog.csdn.net/jason_src/article/details/37757661
There are many ways to get the package name and version number for other apps on your Android phone, which can be obtained directly from the APK package via AAPT or via code on your phone. Obviously, for the product or user to obtain this information, on the phone to obtain more convenient.
Let's look at how to get the package name, version number of the other app on the phone.
Core: Through Packagemanager can get the information we want, such as: program icon, program name, package name, Versionname, Versioncode and so on.
/* * @Author Sun Ruichuan * * */public arraylist
Once you get the information you need, you can put that information into your custom Listadaptar.
Class Myadapter extends Baseadapter {public class Holder {TextView tv_pakagename; TextView Tv_versioncode; TextView Tv_versionname; TextView Tv_appname;imageview Iv_logo;} @Overridepublic int GetCount () {return allprocess.size ();} @Overridepublic hashmap<string, object> getItem (int position) {return allprocess.get (position);} @Overridepublic long Getitemid (int position) {return position;} @Overridepublic view GetView (int position, view Convertview, ViewGroup parent) {Holder Holder; View v;if (Convertview = = null) {holder = new holder (); v = layoutinflater.from (Getapplicationcontext ()). Inflate (r.layout . List_menu, null); holder.tv_pakagename = (TextView) V.findviewbyid (r.id.tv_pakagename); Holder.tv_versioncode = ( TextView) V.findviewbyid (r.id.tv_versioncode); holder.tv_versionname = (TextView) V.findviewbyid (r.id.tv_ Versionname); Holder.iv_logo = (ImageView) V.findviewbyid (R.id.iv_logo); holder.tv_appname = (TextView) V.findviewbyid (r.id.tv_appname); V.settag (holder);} else {v = convertview;holdER = (Holder) V.gettag ();} Holder.tv_pakagename.setText ("Package Name:" + allprocess.get (position). Get ("PackageName"). toString ()); holder.tv_ Versioncode.settext ("Versioncode:" + allprocess.get (position). Get ("Versioncode"). toString ()); holder.tv_ Versionname.settext ("Versionname:" + allprocess.get (position). Get ("Versionname"). toString ()); holder.iv_ Logo.setimagedrawable ((drawable) allprocess.get (position). Get ("Appimage")); Holder.tv_appname.setText ("app Name:" + Allprocess.get (position). Get ("AppName"). toString ()); return v;}}
This completes the corresponding work.