public ArrayList<String> getLivePaperPkgName() {
ArrayList<String> pkgList = new ArrayList<String> ();
List<ResolveInfo> list = mPackageManager.queryIntentServices(
new Intent(WallpaperService.SERVICE_INTERFACE),
PackageManager.GET_META_DATA);
int listSize = list.size();
for (int i = 0; i < listSize; i++) {
ResolveInfo resolveInfo = list.get(i);
ComponentInfo ci = resolveInfo.serviceInfo;
WallpaperInfo info;
try {
info = new WallpaperInfo(mContext, resolveInfo);
} catch (XmlPullParserException e) {
Log.w(TAG, "Skipping wallpaper " + ci, e);
continue;
} catch (IOException e) {
Log.w(TAG, "Skipping wallpaper " + ci, e);
continue;
}
String packageName = info.getPackageName();
pkgList.add(packageName);
}
return pkgList;
}
转载于:https://my.oschina.net/wecome/blog/89388