|
1 | 1 | package com.pronoy.mukhe.todoapplication.Helper;
|
2 | 2 |
|
3 | 3 | import android.app.AlarmManager;
|
4 |
| -import android.app.NotificationChannel; |
5 |
| -import android.app.NotificationManager; |
6 | 4 | import android.app.PendingIntent;
|
7 | 5 | import android.content.BroadcastReceiver;
|
8 | 6 | import android.content.Context;
|
9 | 7 | import android.content.Intent;
|
10 | 8 | import android.media.Ringtone;
|
11 | 9 | import android.media.RingtoneManager;
|
12 | 10 | import android.net.Uri;
|
13 |
| -import android.os.Build; |
14 | 11 | import android.os.Bundle;
|
15 | 12 | import android.support.v4.app.NotificationCompat;
|
16 | 13 |
|
@@ -40,40 +37,18 @@ public void onReceive(Context context, Intent intent) {
|
40 | 37 | 0,
|
41 | 38 | todoIntent,
|
42 | 39 | 0);
|
43 |
| - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
44 |
| - NotificationChannel channel = new NotificationChannel(String |
45 |
| - .valueOf(Constants.NOTIFICATION_CHANNEL_ID), |
46 |
| - Constants.NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); |
47 |
| - NotificationCompat.Builder builder = new NotificationCompat.Builder(context, |
48 |
| - channel.getId()) |
49 |
| - .setSmallIcon(R.drawable.notification_event) |
50 |
| - .setContentTitle(title) |
51 |
| - .setContentText(desc) |
52 |
| - .setPriority(NotificationCompat.PRIORITY_HIGH) |
53 |
| - .setContentIntent(pendingIntent) |
54 |
| - .setChannelId(String.valueOf(Constants.NOTIFICATION_CHANNEL_ID)) |
55 |
| - .setAutoCancel(true); |
56 |
| - NotificationManager notificationManager = (NotificationManager) context |
57 |
| - .getSystemService(Context.NOTIFICATION_SERVICE); |
58 |
| - notificationManager.notify(Constants.NOTIFICATION_ID, builder.build()); |
59 |
| - Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); |
60 |
| - Ringtone ringtone = RingtoneManager.getRingtone(context, uri); |
61 |
| - ringtone.play(); |
62 |
| - } else { |
63 |
| - NotificationCompat.Builder builder = new NotificationCompat.Builder(context) |
64 |
| - .setSmallIcon(R.drawable.notification_event) |
65 |
| - .setContentTitle(title) |
66 |
| - .setContentText(desc) |
67 |
| - .setChannelId(String.valueOf(Constants.NOTIFICATION_CHANNEL_ID)) |
68 |
| - .setPriority(NotificationCompat.PRIORITY_HIGH) |
69 |
| - .setContentIntent(pendingIntent) |
70 |
| - .setAutoCancel(true); |
71 |
| - NotificationManager notificationManager = (NotificationManager) context |
72 |
| - .getSystemService(Context.NOTIFICATION_SERVICE); |
73 |
| - notificationManager.notify(Constants.NOTIFICATION_ID, builder.build()); |
74 |
| - Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); |
75 |
| - Ringtone ringtone = RingtoneManager.getRingtone(context, uri); |
76 |
| - ringtone.play(); |
77 |
| - } |
| 40 | + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, |
| 41 | + String.valueOf(Constants.NOTIFICATION_CHANNEL_ID)) |
| 42 | + .setSmallIcon(R.drawable.notification_event) |
| 43 | + .setContentTitle(title) |
| 44 | + .setContentText(desc) |
| 45 | + .setPriority(NotificationCompat.PRIORITY_HIGH) |
| 46 | + .setContentIntent(pendingIntent) |
| 47 | + .setChannelId(String.valueOf(Constants.NOTIFICATION_CHANNEL_ID)) |
| 48 | + .setAutoCancel(true); |
| 49 | + Constants.NOTIFICATION_MANAGER.notify(Constants.NOTIFICATION_ID, builder.build()); |
| 50 | + Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); |
| 51 | + Ringtone ringtone = RingtoneManager.getRingtone(context, uri); |
| 52 | + ringtone.play(); |
78 | 53 | }
|
79 | 54 | }
|
0 commit comments