2012-02-29 43 views
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); 
+1

不知道,但也许另一个使用相同的通知ID应用程序。尝试创建虚拟应用,使用相同的ID发布通知,反之亦然。 – 2012-02-29 22:35:43

+0

请查看我的编辑。感谢最初的建议,但事实并非如此 – 2012-02-29 23:35:35

回答

0

更改ARGB_8888 565固定这个