1
1
package com .afwsamples .testdpc ;
2
2
3
+ import android .app .Notification ;
4
+ import android .app .NotificationManager ;
3
5
import android .content .BroadcastReceiver ;
4
6
import android .content .Context ;
5
7
import android .content .Intent ;
8
+ import android .support .v7 .app .NotificationCompat ;
9
+ import android .support .v7 .app .NotificationCompat .Builder ;
6
10
import android .text .TextUtils ;
7
11
8
12
import com .afwsamples .testdpc .common .NotificationUtil ;
@@ -27,10 +31,16 @@ public void onReceive(Context context, Intent intent) {
27
31
return ;
28
32
}
29
33
String notificationBody = buildNotificationText (context , packageName , action );
30
- NotificationUtil .showNotification (context ,
31
- R .string .package_changed_notification_title ,
32
- notificationBody ,
33
- PACKAGE_CHANGED_NOTIIFICATION_ID );
34
+ Notification notification = NotificationUtil .getNotificationBuilder (context )
35
+ .setSmallIcon (R .drawable .ic_launcher )
36
+ .setContentTitle (context .getString (R .string .package_changed_notification_title ))
37
+ .setContentText (notificationBody )
38
+ .setStyle (new NotificationCompat .BigTextStyle ().bigText (notificationBody ))
39
+ .setDefaults (Notification .DEFAULT_LIGHTS )
40
+ .build ();
41
+ NotificationManager notificationManager =
42
+ (NotificationManager ) context .getSystemService (Context .NOTIFICATION_SERVICE );
43
+ notificationManager .notify (PACKAGE_CHANGED_NOTIIFICATION_ID , notification );
34
44
}
35
45
36
46
private String getPackageNameFromIntent (Intent intent ) {
0 commit comments