Controlling Android Notification Duration for HeadsUp
<p>I am adding the new HeadsUp notification to my Android app to be shown as an incoming call which will ring for 30 or 40 seconds. The default HeadsUp notification just ring for 10 seconds and then stops. I searched for a while to find a way to make the notification ring for 30 or 40 seconds. It seems that there is nothing could make me control the Notification Ringing duration. </p>

<p><strong>Answering my question</strong>
This was my updated notification initialization code to answer my question:</p>

<pre><code>Notification myNotification = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher)
            .setLargeIcon(remote_picture)
            .setContentIntent(resultPendingIntent)
            .setContentTitle("Vehicle Health Monitor")
            .setVibrate(new long[20])
            .setCategory(Notification.CATEGORY_CALL)
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setContentText(msg)
            .setAutoCancel(false)
            .build();
    mNotificationManager.notify(NOTIFICATION_ID, myNotification);
</code></pre>

<p>So mainly, the solution was to set notification category to <strong>Notification.CATEGORY_CALL</strong></p>