私はこのコードを使用してヘッズアップ通知を作成しています。ヘッドアップ通知を終了し、通常の通知を作成します
private static void showNotificationNew(final Context context,final String title,final String message,final Intent intent, final int notificationId, final boolean isHeaderNotification) {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context.getApplicationContext())
.setSmallIcon(R.drawable.prime_builder_icon)
.setPriority(Notification.PRIORITY_DEFAULT)
.setCategory(Notification.CATEGORY_MESSAGE)
.setContentTitle(title)
.setContentText(message)
.setWhen(0)
.setTicker(context.getString(R.string.app_name));
PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
notificationBuilder.setContentText(message);
if(isHeaderNotification) {
notificationBuilder.setFullScreenIntent(fullScreenPendingIntent, false);
}
notificationBuilder.setContentIntent(fullScreenPendingIntent);
notificationBuilder.setAutoCancel(true);
Notification notification = notificationBuilder.build();
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(notificationId, notification);
}
事があり、通知は、ユーザーの注意を喚起するために、トップ画面の良い部分を占めて表示されますが、数秒後に、それは却下すべきであると、通常の通知が表示されます。
しかし、このコードではそうしていません。通知がユーザーを却下するまで、すべてのトップ画面を占有し続けます。
Handlerを使用して数秒後に同じIDの別の通常の通知を作成すると思っていますが、これを行うより良い方法があるかどうかを知りたいと思います。
WhatsAppの例に従って、私が望む動作をシミュレートします。
恐ろしい:
これはヘッドアップ通知を作業の一例です!ありがとうございました。 – leonvian
フルスクリーンインテントを設定すると、ヘッズアップ通知が自動的に却下されるのを防ぐことに興味があります。私の電話が鳴っていると思うと意味がありますが、何が起こっているのかを追跡するために私はしばらく時間がかかりました。 –