version:1.0.0
update:更换包名 bugfixes:
This commit is contained in:
72
app/src/main/java/com/xxpatx/os/bean/DailyAppBean.java
Normal file
72
app/src/main/java/com/xxpatx/os/bean/DailyAppBean.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.xxpatx.os.bean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.xxpatx.os.BuildConfig;
|
||||
import com.xxpatx.os.utils.IconUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DailyAppBean implements Serializable {
|
||||
private static final long serialVersionUID = 5054284058523960678L;
|
||||
|
||||
String appName;
|
||||
String packageName;
|
||||
String className;
|
||||
|
||||
public DailyAppBean(String appName, String packageName, String className) {
|
||||
this.appName = appName;
|
||||
this.packageName = packageName;
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public Drawable getIcon(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
ApplicationInfo info = null;
|
||||
try {
|
||||
info = pm.getApplicationInfo(packageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (info == null) {
|
||||
return null;
|
||||
} else {
|
||||
int i = IconUtils.appClassNameList.indexOf(packageName);
|
||||
if (i != -1) {
|
||||
String val = IconUtils.appIconList.get(i);
|
||||
int resID = context.getResources().getIdentifier(val, "drawable", BuildConfig.APPLICATION_ID);
|
||||
if (resID != 0) {
|
||||
return context.getResources().getDrawable(resID);
|
||||
}
|
||||
}
|
||||
return info.loadIcon(pm);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user