0
部分手機不支持大型通知。那麼我怎麼能在運行時知道我的notif大小或平常大小?另外我需要它支持控制按鈕。 這裏是我的大通知符代碼:Android小型和大型通知
RemoteViews remoteViews = new RemoteViews(getPackageName(),
settings.getAttributeId(settings.getThemeByString(), R.attr.theme_dependent_notification));
remoteViews.setOnClickPendingIntent(R.id.prev, ppreviousIntent);
remoteViews.setOnClickPendingIntent(R.id.play, pplayIntent);
remoteViews.setOnClickPendingIntent(R.id.next, pnextIntent);
remoteViews.setOnClickPendingIntent(R.id.close, pcloseIntent);
remoteViews.setImageViewBitmap(R.id.cover, icon);
remoteViews.setTextViewText(R.id.name, title);
remoteViews.setTextViewText(R.id.artist, text);
remoteViews.setTextViewText(R.id.count, count);
if (isPlayerActive) remoteViews.setImageViewResource(R.id.play, R.drawable.pause);
else remoteViews.setImageViewResource(R.id.play, R.drawable.play);
notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.equalizer_icon)
.setContentTitle(title)
.setContentText(text)
.setTicker(getString(R.string.app_name))
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_MAX)
.build();
notification.bigContentView = remoteViews;
但是自定義佈局呢?我需要notif的變種:對於手機來說,它可以顯示大而平常的手機尺寸,而手機不能。自定義佈局上帶有控制按鈕的通知 –
您是否試過https://stackoverflow.com/questions/21237495/create-custom-big-notifications或https://stackoverflow.com/questions/18367631/change-notification-layout? – isabsent
你不瞭解我。我知道如何進行自定義佈局。你可以看到我的代碼。當不允許的情況下,我不知道如何顯示通常尺寸的notif。 –