recyclerview with notification list
This commit is contained in:
@@ -3,6 +3,10 @@ package net.headlezz.notificationlogger;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class PackageUtils {
|
||||
|
||||
@@ -12,5 +16,38 @@ public class PackageUtils {
|
||||
return (String) pm.getApplicationLabel(appInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context
|
||||
* @param packageName
|
||||
* @return Drawable or Null
|
||||
*/
|
||||
public static Drawable getApplicationLauncherIcon(Context context, String packageName) {
|
||||
try {
|
||||
return context.getPackageManager().getApplicationIcon(packageName);
|
||||
} catch(PackageManager.NameNotFoundException e) {
|
||||
Timber.w("package not found: " + packageName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context
|
||||
* @param packageName
|
||||
* @param iconId
|
||||
* @return Drawable or Null
|
||||
*/
|
||||
public static Drawable getApplicationDrawable(Context context, String packageName, int iconId) {
|
||||
try {
|
||||
Resources res = context.getPackageManager().getResourcesForApplication(packageName);
|
||||
return res.getDrawable(iconId);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Timber.w("package not found: " + packageName);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user