Android 某些手机上没有显示通知
我的一些用户报告通知在应该显示的时候没有显示。它在所有模拟器和我的手机上都能正常工作。。有什么想法吗Android 某些手机上没有显示通知,android,Android,我的一些用户报告通知在应该显示的时候没有显示。它在所有模拟器和我的手机上都能正常工作。。有什么想法吗 // configure the intent if (SongList.theclass == "SongList") { playIntent = new Intent(MyService.this, SongList.class); } else if (SongList.theclass == "Favorites") { playInte
// 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);
将ARGB_8888更改为565修复了此问题不确定,但可能另一个应用程序使用相同的通知id。请尝试创建虚拟应用程序,使用相同的id发布通知,反之亦然。请查看我的编辑。谢谢你最初的建议,但事实并非如此