如何在安卓手机安装java软件_java实现获取安卓设备里已安装的软件包

之前的文章向大家介绍了几个项目中常用的实用功能,那么在这篇文中,我将向大家介绍如何获取Android手机中已经安装的手机应用程序,好了,废话不多说,直接上代码

private String getInstalledAppListAsString(){

PackageManager pm = context.getPackageManager();

List apps = pm.getInstalledApplications(PackageManager.GET_GIDS);

StringBuffer stringBuffer = new StringBuffer();

for (ApplicationInfo app : apps) {

if(pm.getLaunchIntentForPackage(app.packageName) != null) {

// apps with launcher intent

if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 1) {

// updated system apps

} else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {

// system apps

} else {

// user installed apps

stringBuffer.append(app.packageName).append(';');

}

}

}

return stringBuffer.toString();

}

下面我们看看具体如何获取各个应用的相关信息呢

package cn.lyz.mobilesafe.domain;

import android.graphics.drawable.Drawable;

/**

* 获取的应用基本信息实体类

* @author liuyazhuang

*

*/

public class AppInfo {

//图标

private Drawable app_icon;

//应用名称

private String app_name;

//应用版本号

private String app_version;

//应用包名

private String packagename;

//是否是用户app

private boolean isUserApp;

public AppInfo() {

super();

// TODO Auto-generated constructor stub

}

public AppInfo(Drawable app_icon, String app_name, String app_version,

String packagename) {

super();

this.app_icon = app_icon;

this.app_name = app_name;

this.app_version = app_version;

this.packagename = packagename;

}

public AppInfo(Drawable app_icon, String app_name, String app_version,

String packagename, boolean isUserApp) {

super();

this.app_icon = app_icon;

this.app_name = app_name;

this.app_version = app_version;

this.packagename = packagename;

this.isUserApp = isUserApp;

}

public Drawable getApp_icon() {

return app_icon;

}

public void setApp_icon(Drawable app_icon) {

this.app_icon = app_icon;

}

public String getApp_name() {

return app_name;

}

public void setApp_name(String app_name) {

this.app_name = app_name;

}

public String getApp_version() {

return app_version;

}

public void setApp_version(String app_version) {

this.app_version = app_version;

}

public String getPackagename() {

return packagename;

}

public void setPackagename(String packagename) {

this.packagename = packagename;

}

public boolean isUserApp() {

return isUserApp;

}

public void setUserApp(boolean isUserApp) {

this.isUserApp = isUserApp;

}

@Override

public String toString() {

return "AppInfo [app_icon=" + app_icon + ", app_name=" + app_name

+ ", app_version=" + app_version + ", packagename="

+ packagename + ", isUserApp=" + isUserApp + "]";

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值