Android Progress Notification module

Ahad, 9 November 2014, 3:18 pm0

Android Progress Notification module is a module to display notification in Android notification area which contains progress bar. In addition, it also support setting the number of notification, useful if you have a number of grouped notifications.

nc_progress_notif_1 nc_progress_notif_2

To create a notification:

var ProgressNotif = require('nc.progressnotification');
var notif = ProgressNotif.createNotification({
    id: 1234, // required
    number: 1,
    icon: Ti.App.Android.R.drawable.appicon,
    pendingIntent: getPendingIntent(),
    title: 'Notification title',
    text: 'Notification message'

// notify progress, 0 to 100

// can also be called with initial value
// notif.notify(1);

Note that initially the progress notification is shown as ongoing notification with indeterminate progress bar, if you don’t set any initial value. Then, as the progress value being updated, it become determinate progress bar, still an ongoing notification. Ongoing notification means it cannot be cancelled or cleared from Android notification area. Only when the progress value is set as 100, notification is automatically updated to remove the progress bar & change into normal notification (can be cleared from notification area).

To update progress value:

notif.notify(50); // 50% completion

To cancel the notification:

notif = null;

getPendingIntent() returns Ti.Android.PendingIntent object, code below demonstrate pending intent that will resume app if it’s running, or launch the app if it isn’t

function getPendingIntent() {
    var intent = Ti.Android.currentActivity.intent;
    return Ti.Android.createPendingIntent({
        intent: intent,
        updateCurrentIntent: true

To see the details of how this module work, refer to example/app.js file

Download from Github

Tulis komen: