某些手机​​上没有显示通知

时间:2012-02-29 21:47:43

标签: android

我的一些用户报告说该通知没有显示。它适用于所有模拟器和我的手机..任何想法?

// 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 个答案:

答案 0 :(得分:0)

将ARGB_8888更改为565修复了此