Skip to content

Commit ba10043

Browse files
committed
Mute the sound of package changes notification
Fix: 62655640 Change-Id: Ie2f27cfffeed6ba8ef382238d109fd4065cac747
1 parent 70c9e22 commit ba10043

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

app/src/main/java/com/afwsamples/testdpc/PackageMonitorReceiver.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package com.afwsamples.testdpc;
22

3+
import android.app.Notification;
4+
import android.app.NotificationManager;
35
import android.content.BroadcastReceiver;
46
import android.content.Context;
57
import android.content.Intent;
8+
import android.support.v7.app.NotificationCompat;
9+
import android.support.v7.app.NotificationCompat.Builder;
610
import android.text.TextUtils;
711

812
import com.afwsamples.testdpc.common.NotificationUtil;
@@ -27,10 +31,16 @@ public void onReceive(Context context, Intent intent) {
2731
return;
2832
}
2933
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);
3444
}
3545

3646
private String getPackageNameFromIntent(Intent intent) {

0 commit comments

Comments
 (0)