Skip to content

Commit fcd3707

Browse files
committed
Add Util class for showing notifications [DO NOT MERGE]
Change-Id: I4e0dc1b7442aeb33fd51c62341764f5f8056a3e2
1 parent e24f478 commit fcd3707

File tree

1 file changed

+42
-0
lines changed
  • app/src/main/java/com/afwsamples/testdpc/common

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (C) 2016 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.afwsamples.testdpc.common;
18+
19+
import android.app.Notification;
20+
import android.app.NotificationManager;
21+
import android.content.Context;
22+
23+
import com.afwsamples.testdpc.R;
24+
25+
/**
26+
* Common utility functions.
27+
*/
28+
public class Util {
29+
30+
public static void showNotification(Context context, int titleId, String msg,
31+
int notificationId) {
32+
NotificationManager mNotificationManager =
33+
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
34+
Notification notification = new Notification.Builder(context)
35+
.setSmallIcon(R.drawable.ic_launcher)
36+
.setContentTitle(context.getString(titleId))
37+
.setContentText(msg)
38+
.setStyle(new Notification.BigTextStyle().bigText(msg))
39+
.build();
40+
mNotificationManager.notify(notificationId, notification);
41+
}
42+
}

0 commit comments

Comments
 (0)