本文整理汇总了Java中android.content.pm.PackageItemInfo类的典型用法代码示例。如果您正苦于以下问题:Java PackageItemInfo类的具体用法?Java PackageItemInfo怎么用?Java PackageItemInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PackageItemInfo类属于android.content.pm包,在下文中一共展示了PackageItemInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
@Override
protected List<AppInfo> doInBackground(Object... objects) {
List<AppInfo> labelsPackages = new ArrayList<>();
PackageManager packageManager = activity.getPackageManager();
Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (PackageItemInfo appInfo : appInfos) {
String packageName = appInfo.packageName;
if (!isHidden(packageName)) {
CharSequence label = appInfo.loadLabel(packageManager);
Drawable icon = appInfo.loadIcon(packageManager);
if (label != null) {
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
}
}
}
Collections.sort(labelsPackages);
return labelsPackages;
}
示例2: doInBackground
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
@Override
protected List<AppInfo> doInBackground(Object... objects) {
List<AppInfo> labelsPackages = new ArrayList<>();
PackageManager packageManager = activity.getPackageManager();
Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (PackageItemInfo appInfo : appInfos) {
String packageName = appInfo.packageName;
if (!isHidden(packageName)) {
CharSequence label = appInfo.loadLabel(packageManager);
Drawable icon = appInfo.loadIcon(packageManager);
if (label != null) {
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
}
}
}
Collections.sort(labelsPackages);
return labelsPackages;
}
示例3: doInBackground
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
@Override
protected List<AppInfo> doInBackground(Object... objects) {
List<AppInfo> labelsPackages = new ArrayList<>();
PackageManager packageManager = activity.getPackageManager();
Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (PackageItemInfo appInfo : appInfos) {
String packageName = appInfo.packageName;
if (!isHidden(packageName)) {
CharSequence label = appInfo.loadLabel(packageManager);
Drawable icon = appInfo.loadIcon(packageManager);
if (label != null) {
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
}
}
}
Collections.sort(labelsPackages);
return labelsPackages;
}
示例4: doInBackground
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
@Override
protected List<AppInfo> doInBackground(Void... objects) {
List<AppInfo> labelsPackages = new ArrayList<AppInfo>();
PackageManager packageManager = activity.getPackageManager();
Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (PackageItemInfo appInfo : appInfos) {
String packageName = appInfo.packageName;
if (!isHidden(packageName)) {
CharSequence label = appInfo.loadLabel(packageManager);
Drawable icon = appInfo.loadIcon(packageManager);
if (label != null) {
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
}
}
}
Collections.sort(labelsPackages);
return labelsPackages;
}
示例5: doInBackground
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
@Override
protected List<AppInfo> doInBackground(Void... objects) {
List<AppInfo> labelsPackages = new ArrayList<AppInfo>();
PackageManager packageManager = activity.getPackageManager();
Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (PackageItemInfo appInfo : appInfos) {
String packageName = appInfo.packageName;
if (!isHidden(packageName)) {
CharSequence label = appInfo.loadLabel(packageManager);
Drawable icon = appInfo.loadIcon(packageManager);
if (label != null) {
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
}
}
}
Collections.sort(labelsPackages);
return labelsPackages;
}
示例6: substract
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
<T extends PackageItemInfo>List substract(List<T> left, List<T> right){
List<T> list = new ArrayList<>();
for (int i = 0; i < left.size() ; i++) {
boolean found = false;
for (int j = 0; j < right.size() ; j++) {
if (left.get(i).name.equals(right.get(j).name)){
found = true;
break;
}
}
if (!found) {
list.add(left.get(i));
}
}
return list;
}
示例7: checkServices
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
private static void checkServices(Context context, PackageInfo packageInfo) {
Map hashMap = new HashMap();
hashMap.put("com.xiaomi.push.service.XMPushService", new Boolean[]{Boolean.valueOf(true),
Boolean.valueOf(false)});
hashMap.put(PushMessageHandler.class.getCanonicalName(), new Boolean[]{Boolean.valueOf
(true), Boolean.valueOf(true)});
hashMap.put(MessageHandleService.class.getCanonicalName(), new Boolean[]{Boolean.valueOf
(true), Boolean.valueOf(false)});
if (packageInfo.services != null) {
for (PackageItemInfo packageItemInfo : packageInfo.services) {
if (!TextUtils.isEmpty(packageItemInfo.name) && hashMap.containsKey
(packageItemInfo.name)) {
Boolean[] boolArr = (Boolean[]) hashMap.remove(packageItemInfo.name);
if (boolArr[0].booleanValue() != packageItemInfo.enabled) {
throw new a(String.format("Wrong attribute: %n <service " +
"android:name=\"%1$s\" .../> android:enabled should be %<b.", new
Object[]{packageItemInfo.name, boolArr[0]}), packageItemInfo);
} else if (boolArr[1].booleanValue() != packageItemInfo.exported) {
throw new a(String.format("Wrong attribute: %n <service " +
"android:name=\"%1$s\" .../> android:exported should be %<b.",
new Object[]{packageItemInfo.name, boolArr[1]}), packageItemInfo);
} else if (hashMap.isEmpty()) {
break;
}
}
}
}
if (!hashMap.isEmpty()) {
throw new a(String.format("<service android:name=\"%1$s\" /> is missing or disabled" +
".", new Object[]{hashMap.keySet().iterator().next()}), null);
}
}
示例8: findAndCheckReceiverInfo
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
private static void findAndCheckReceiverInfo(PackageManager packageManager, Intent intent,
Class<?> cls, Boolean[] boolArr) {
int i;
for (ResolveInfo resolveInfo : packageManager.queryBroadcastReceivers(intent, 16384)) {
PackageItemInfo packageItemInfo = resolveInfo.activityInfo;
if (packageItemInfo != null && cls.getCanonicalName().equals(packageItemInfo.name)) {
if (boolArr[0].booleanValue() != packageItemInfo.enabled) {
throw new a(String.format("Wrong attribute: %n <receiver " +
"android:name=\"%1$s\" .../> android:enabled should be %<b.", new
Object[]{packageItemInfo.name, boolArr[0]}), packageItemInfo);
} else if (boolArr[1].booleanValue() != packageItemInfo.exported) {
throw new a(String.format("Wrong attribute: %n <receiver " +
"android:name=\"%1$s\" .../> android:exported should be %<b.", new
Object[]{packageItemInfo.name, boolArr[1]}), packageItemInfo);
} else {
i = 1;
if (i == 0) {
throw new a(String.format("<receiver android:name=\"%1$s\" /> is missing " +
"or disabled.", new Object[]{cls.getCanonicalName()}), null);
}
}
}
}
i = 0;
if (i == 0) {
throw new a(String.format("<receiver android:name=\"%1$s\" /> is missing or disabled" +
".", new Object[]{cls.getCanonicalName()}), null);
}
}
示例9: parsePackageItemInfo
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
private boolean parsePackageItemInfo(DynamicApkInfo owner, PackageItemInfo outInfo,
String[] outError, String tag, TypedArray sa,
int nameRes, int labelRes, int iconRes, int logoRes, int bannerRes) {
String name = sa.getString(nameRes);
if (name == null) {
outError[0] = tag + " does not specify android:name";
return false;
}
outInfo.name
= buildClassName(owner.applicationInfo.packageName, name, outError);
if (outInfo.name == null) {
return false;
}
int iconVal = sa.getResourceId(iconRes, 0);
if (iconVal != 0) {
outInfo.icon = iconVal;
outInfo.nonLocalizedLabel = null;
}
int logoVal = sa.getResourceId(logoRes, 0);
if (logoVal != 0) {
outInfo.logo = logoVal;
}
int bannerVal = sa.getResourceId(bannerRes, 0);
if (bannerVal != 0) {
outInfo.banner = bannerVal;
}
TypedValue v = sa.peekValue(labelRes);
if (v != null && (outInfo.labelRes=v.resourceId) == 0) {
outInfo.nonLocalizedLabel = v.coerceToString();
}
outInfo.packageName = owner.packageName;
return true;
}
示例10: Component
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
public Component(final ParseComponentArgs args, final ComponentInfo outInfo) {
this(args, (PackageItemInfo)outInfo);
if (args.outError[0] != null) {
return;
}
if (args.processRes != 0) {
CharSequence pname;
if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) {
// pname = args.sa.getNonConfigurationString(args.processRes,
// Configuration.NATIVE_CONFIG_VERSION);
pname = args.sa.getNonResourceString(args.processRes);
} else {
// Some older apps have been seen to use a resource reference
// here that on older builds was ignored (with a warning). We
// need to continue to do this for them so they don't break.
pname = args.sa.getNonResourceString(args.processRes);
}
outInfo.processName = buildProcessName(owner.applicationInfo.packageName,
owner.applicationInfo.processName, pname,
args.sepProcesses, args.outError);
}
if (args.descriptionRes != 0) {
outInfo.descriptionRes = args.sa.getResourceId(args.descriptionRes, 0);
}
outInfo.enabled = args.sa.getBoolean(args.enabledRes, true);
}
示例11: loadItemIcon
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
public static Drawable loadItemIcon(PackageManager object,
PackageItemInfo itemInfo, ApplicationInfo appInfo) {
try {
Method m = object.getClass().getDeclaredMethod("loadItemIcon", new Class[]{PackageItemInfo.class, ApplicationInfo.class});
return (Drawable) m.invoke(object, new Object[]{itemInfo, appInfo});
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
示例12: parsePackageItem
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
/**
* @see <href a="http://developer.android.com/reference/android/content/pm/PackageItemInfo.html">PackageItemInfo</href>
*
* @param parser
* @param info
*/
private static void parsePackageItem(XmlResourceParser parser,
PackageItemInfo info) {
final int attCount = parser.getAttributeCount();
for (int i = 0; i < attCount; i++) {
String attName = parser.getAttributeName(i);
String attValue = parser.getAttributeValue(i);
if (ATTR_BANNER.equals(attName) && afterApiLevel(20)) {
info.logo = toResId(attValue);
} else if (ATTR_ICON.equals(attName)) {
info.icon = toResId(attValue);
} else if (ATTR_NAME.equals(attName)) {
String cName = attValue;
info.name = cName;
} else if (ATTR_LABEL.equals(attName)) {
if (attValue.startsWith("@")) {
info.labelRes = Integer.parseInt(attValue.substring(1));
} else {
info.nonLocalizedLabel = attValue;
}
} else if (ATTR_LOGO.equals(attName) && afterApiLevel(9)) {
info.logo = toResId(attValue);
} else {
if (LOG_UN_HANDLED_ITEM) {
Log.w(TAG, "un-handled att: " + attName + "=" + attValue);
}
}
}
}
示例13: loadItemIcon
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
/** @hide */
@Override public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
return mBase.loadItemIcon(itemInfo, appInfo);
}
示例14: loadUnbadgedItemIcon
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
/** @hide */
@Override public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
return mBase.loadUnbadgedItemIcon(itemInfo, appInfo);
}
示例15: a
import android.content.pm.PackageItemInfo; //导入依赖的package包/类
public a(String str, PackageItemInfo packageItemInfo) {
super(str);
this.a = packageItemInfo;
}