1
我的一些用戶報告說,通知在應該顯示時未顯示。它適用於所有的模擬器和我的手機。任何想法?某些電話上沒有顯示通知
// 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);
我得到了我的手在這種情況發生,當我註釋掉這條線,通知將再次顯示..任何想法基於此?
if (SongList.bitmap != null) {
notification.contentView.setImageViewBitmap(R.id.notifimage, SongList.bitmap);
} else {
notification.contentView.setImageViewResource(R.id.notifimage, R.drawable.icon);
}
如何創建位圖:
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);
不知道,但也許另一個使用相同的通知ID應用程序。嘗試創建虛擬應用,使用相同的ID發佈通知,反之亦然。 – 2012-02-29 22:35:43
請查看我的編輯。感謝最初的建議,但事實並非如此 – 2012-02-29 23:35:35