Skip to content

Commit

Permalink
Fix(Compat): fixTaskDescription fail on some devices
Browse files Browse the repository at this point in the history
  • Loading branch information
cmzy committed Feb 15, 2016
1 parent b172482 commit 5548f00
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,23 @@ private void onActivityOnNewIntent(Activity activity, Intent intent) throws Remo

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void fixTaskDescription(Activity activity, ActivityInfo targetInfo) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
PackageManager pm = mHostContext.getPackageManager();
String lablel = String.valueOf(targetInfo.loadLabel(pm));
Drawable icon = targetInfo.loadIcon(pm);
Bitmap bitmap = null;
if (icon instanceof BitmapDrawable) {
bitmap = ((BitmapDrawable) icon).getBitmap();
}
if (bitmap != null) {
activity.setTaskDescription(new android.app.ActivityManager.TaskDescription(lablel, bitmap));
} else {
activity.setTaskDescription(new android.app.ActivityManager.TaskDescription(lablel));
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
PackageManager pm = mHostContext.getPackageManager();
String lablel = String.valueOf(targetInfo.loadLabel(pm));
Drawable icon = targetInfo.loadIcon(pm);
Bitmap bitmap = null;
if (icon instanceof BitmapDrawable) {
bitmap = ((BitmapDrawable) icon).getBitmap();
}
if (bitmap != null) {
activity.setTaskDescription(new android.app.ActivityManager.TaskDescription(lablel, bitmap));
} else {
activity.setTaskDescription(new android.app.ActivityManager.TaskDescription(lablel));
}
}
} catch (Throwable e) {
Log.w(TAG, "fixTaskDescription fail", e);
}
}

Expand Down

0 comments on commit 5548f00

Please sign in to comment.