转载请注明出处:http://blog.csdn.net/jason_src/article/details/37757661

获取Android手机上其它应用的包名及版本方法有非常多,能够通过AAPT从APK包中直接获取。也能够通过代码在手机上获取。显然,对于产品或者用户来说要获取这些信息,在手机上获取更为简便。

以下我们来看下怎样在手机上获取其它应用的包名、版本。

核心:通过PackageManager能够获取到我们想要的信息,比如:程序图标、程序名称、包名、VersionName、VersionCode等。

	/*
* @Author Sun Ruichuan
*
* */ public ArrayList<HashMap<String, Object>> getItems(Context context) { PackageManager pckMan = context.getPackageManager();
ArrayList<HashMap<String, Object>> items = new ArrayList<HashMap<String, Object>>(); List<PackageInfo> packageInfo = pckMan.getInstalledPackages(0); for (PackageInfo pInfo : packageInfo) { HashMap<String, Object> item = new HashMap<String, Object>(); item.put("appimage", pInfo.applicationInfo.loadIcon(pckMan));
item.put("packageName", pInfo.packageName);
item.put("versionCode", pInfo.versionCode);
item.put("versionName", pInfo.versionName);
item.put("appName", pInfo.applicationInfo.loadLabel(pckMan).toString()); items.add(item); } return items;
}

在获取到所须要的信息后就可以将这些信息放入到自己定义的ListAdaptar里。

class MyAdapter extends BaseAdapter {

		public class Holder {
TextView tv_pakagename;
TextView tv_versioncode;
TextView tv_versionname;
TextView tv_appname;
ImageView iv_logo;
} @Override
public int getCount() {
return allProcess.size();
} @Override
public HashMap<String, Object> getItem(int position) {
return allProcess.get(position);
} @Override
public long getItemId(int position) {
return position;
} @Override
public 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("包名:"
+ 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名称:"
+ allProcess.get(position).get("appName").toString()); return v;
} }

这样就完毕了对应的工作。

在Android手机上获取其它应用的包名及版本的更多相关文章

  1. Android 在Android手机上获取其他应用的包名及版本号

    获取Android手机上其他应用的包名及版本号方法有很多,可以通过AAPT从APK包中直接获取,也可以通过代码在手机上获取.显然,对于产品或者用户来说要获取这些信息,在手机上获取更为简便. 下面我们来 ...

  2. Android 手机上获取手机当前上网IP地址

      [转] 原文              Android 手机上获取手机当前上网IP地址                (手机网关给手机号分配的IP) 每个手机上网通过移动网关的时候,网关都会给该手 ...

  3. Android 手机上获取物理唯一标识码[转]

    所有添加有谷歌账户的设备可以返回一个 ANDROID_ID 所有的CDMA设备对于 ANDROID_ID 和 TelephonyManager.getDeviceId() 返回相同的值(只要在设置时添 ...

  4. Android 手机上获取物理唯一标识码

    唯一标识码这东西在网络应用中非常有用,例如检测是否重复注册之类的. import android.provider.Settings.Secure;private String android_id ...

  5. Mac上查看当前安卓手机上打开的app的包名和主程序入口

    1.连接上手机,数据线链接或者无线连接随便 2.打开你需要查看的app 3.打开终端,输入命令: adb shell dumpsys window w |grep \/ |grep name=

  6. Android Studio上修改项目(module)的包名(Package Name)

    当你对着包名右击,查找Refactor(重构)下的Rename(快捷键:SHIFT+F6)时,弹出来的仅仅是包名最后一个路径的名称,如下图: 但你往往希望修改整个包名,比如exmple,所以你需要以下 ...

  7. 如何在 Android 手机上实现抓包?

    如何在 Android 手机上实现抓包? http://www.zhihu.com/question/20467503 我想知道某个应用究竟在数据提交到哪里,提交了什么.网上的教程太复杂,不想麻烦.有 ...

  8. Android 手机上安装并运行 Ubuntu 12.04

    ubuntu.sh脚本的原地址变动了,导致下载不了,现在更新了网盘地址.小技巧:遇到一些下载失效的时候可以试一试p2p下载工具(如 easyMule.迅雷等)试一试,说不定有人分享过~* —————— ...

  9. xe5 android 手机上使用sqlite [转]

    在android手机上怎样使用sqlite数据库,这里用Navigator实现 增删改查. 1.新建firemonkey mobile application 2.选择blank applicatio ...

随机推荐

  1. Oracle Database 12c Release 1 Installation On Oracle Linux 6.4 x86_64

    Create groups and users [root@vmdb12c ~]# groupadd oinstall [root@vmdb12c ~]# groupadd dba [root@vmd ...

  2. 1104--DNA排序

    问题描述: 逆序数可以用来描述一个序列混乱程度的量.例如,“DAABEC”的逆序数为5,其中D大于它右边的4个数·,E大于它右边的1的个数,4+1=5,又如,“ZWQM”的逆序数为3+2+1+0=6. ...

  3. 《Clean Code》重点内容总结

    读书笔记请见Github博客:http://wuxichen.github.io/Myblog/reading/2014/10/06/CleanCode.html

  4. Java chapter04-1

    public class CPU { int speed; //获得speed的值 public void setSpeed(int m){ speed = m; } //返回speed的值 publ ...

  5. SQL Server SQL高级查询语句小结(转)

    --select select * from student; --all 查询所有 select all sex from student; --distinct 过滤重复 select disti ...

  6. 介绍一款开源的类Excel电子表格软件

     Excel一直以霸主的地位,占领了Windows桌面表格软件市场No 1,与此同一时候,Office套装产品差点儿成为了IT行业的标配办公技能.有无相似Excel的桌面程序,绿色版,实现主要的数 ...

  7. c++11 stl atomic_flag 样例

    Author:DriverMonkey Mail:bookworepeng@Hotmail.com Phone:13410905075 QQ:196568501 測试环境:Win7 64 bit 编译 ...

  8. 【HTML相关】iframe+javascript实现一个表单提交后多个处理文件按序处理

    最近在弄一个网页的问题,总结如下. [问题描述] 页面中包括以下几个部分:1)表单form,供用户输入图片文件:2)iframe1,显示a.php文件的内容,a.php接收客户端图片并保存,后台程序处 ...

  9. python 拼写检查代码(怎样写一个拼写检查器)

    原文:http://norvig.com/spell-correct.html 翻译:http://blog.youxu.info/spell-correct.html 怎样写一个拼写检查器 Pete ...

  10. 说服式设计(persuasive design)的行为模型

    转自:http://www.sharetk.com/html/ued/User-Research/1404.html 一 模型简介 BJ Fogg提出了一个新的理解人类行为的模型,他称之为Fogg b ...