summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget/Toast.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/widget/Toast.java')
-rw-r--r--core/java/android/widget/Toast.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java
index 4b31af0..e8dccab 100644
--- a/core/java/android/widget/Toast.java
+++ b/core/java/android/widget/Toast.java
@@ -18,6 +18,7 @@ package android.widget;
import android.annotation.IntDef;
import android.annotation.StringRes;
+import android.app.ActivityManager;
import android.app.INotificationManager;
import android.app.ITransientNotification;
import android.content.Context;
@@ -405,14 +406,18 @@ public class Toast {
ImageView appIcon = (ImageView) mView.findViewById(android.R.id.icon);
if (appIcon != null) {
- PackageManager pm = context.getPackageManager();
- Drawable icon = null;
- try {
- icon = pm.getApplicationIcon(packageName);
- } catch (PackageManager.NameNotFoundException e) {
- // nothing to do
+ ActivityManager am =
+ (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ if (!am.isPackageInForeground(packageName)) {
+ PackageManager pm = context.getPackageManager();
+ Drawable icon = null;
+ try {
+ icon = pm.getApplicationIcon(packageName);
+ } catch (PackageManager.NameNotFoundException e) {
+ // nothing to do
+ }
+ appIcon.setImageDrawable(icon);
}
- appIcon.setImageDrawable(icon);
}
mWM = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
// We can resolve the Gravity here by using the Locale for getting