-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathStatusNotificationIntentGruntPreprocess.java
More file actions
31 lines (25 loc) · 1.2 KB
/
StatusNotificationIntentGruntPreprocess.java
File metadata and controls
31 lines (25 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// This class is used on all Androids below Honeycomb
package com.phonegap.plugins.statusBarNotification;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
// @ifdef $PACKAGE_NAME
import /* @echo $PACKAGE_NAME */.R;
// @endif
public class StatusNotificationIntent {
public static Notification buildNotification( Context context, CharSequence tag, CharSequence contentTitle, CharSequence contentText, int flag ) {
int icon = R.drawable.notification;
long when = System.currentTimeMillis();
Notification noti = new Notification(icon, contentTitle, when);
noti.flags |= flag;
PackageManager pm = context.getPackageManager();
Intent notificationIntent = pm.getLaunchIntentForPackage(context.getPackageName());
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
notificationIntent.putExtra("notificationTag", tag);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
noti.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
return noti;
}
}