Some of my users are reporting that the notification is not being displayed when it should. It works fine on all emulators and my phone.. any ideas?
// configure the intent
if (SongList.theclass == "SongList") {
playIntent = new Intent(MyService.this, SongList.class);
} else if (SongList.theclass == "Favorites") {
playIntent = new Intent(MyService.this, Favorites.class);
} else if (SongList.theclass == "TopTen") {
playIntent = new Intent(MyService.this, TopTen.class);
} else {
playIntent = new Intent(MyService.this, SongList.class);
}
playIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
final PendingIntent pendingIntent = PendingIntent.getActivity(MyService.this, 0, playIntent, 0);
notification = new Notification(R.drawable.playicon, "Buffering...", System
.currentTimeMillis());
notification.contentView = new RemoteViews(getPackageName(), R.layout.custom_notification2);
notification.contentIntent = pendingIntent;
if (SongList.bitmap != null) {
notification.contentView.setImageViewBitmap(R.id.notifimage, SongList.bitmap);
} else {
notification.contentView.setImageViewResource(R.id.notifimage, R.drawable.icon);
}
notification.contentView.setTextViewText(R.id.notiftitle, "Now Playing");
notification.contentView.setTextViewText(R.id.notiftext, songname);
notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT;
mNotificationManager = (NotificationManager) getApplicationContext().getSystemService(
Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(4, notification);
I got my hands on a phone this happens to and when I comment out this line, the notification will display again.. any ideas based off this?
if (SongList.bitmap != null) {
notification.contentView.setImageViewBitmap(R.id.notifimage, SongList.bitmap);
} else {
notification.contentView.setImageViewResource(R.id.notifimage, R.drawable.icon);
}
How I create the bitmap:
drawable = songimage.getDrawable();
bitmap = Bitmap.createBitmap(screenWidth, screenWidth, Bitmap.Config.ARGB_8888);
//bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true); // workaround
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, screenWidth, screenWidth);
drawable.draw(canvas);
Changing ARGB_8888 to 565 fixed this