多平台统一管理软件接口,如何实现多平台统一管理软件接口
216
2023-07-27
java实现获取安卓设备里已安装的软件包
之前的文章向大家介绍了几个项目中常用的实用功能,那么在这篇文中,我将向大家介绍如何获取android手机中已经安装的手机应用程序,好了,废话不多说,直接上代码
private String getInstalledAppListAsString(){
PackageManager pm = context.getPackageManager();
List
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) ==http:// 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, booljvhZyXanzean 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 + "]";
}
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~