22
33
44import android .app .Application ;
5+ import android .app .NotificationChannel ;
6+ import android .app .NotificationManager ;
7+ import android .content .Context ;
8+ import android .os .Build ;
59import android .os .Handler ;
610import android .os .Looper ;
711
812import com .cloudinary .android .LogLevel ;
913import com .cloudinary .android .MediaManager ;
1014import com .cloudinary .android .policy .GlobalUploadPolicy ;
1115import com .cloudinary .android .policy .UploadPolicy ;
16+ import com .cloudinary .android .sample .R ;
1217
1318public class MainApplication extends Application {
19+ public static final String NOTIFICATION_CHANNEL_ID = "CLOUDINARY_CHANNEL" ;
1420 static MainApplication _instance ;
1521 private Handler mainThreadHandler ;
1622
@@ -36,9 +42,24 @@ public void onCreate() {
3642 .networkPolicy (UploadPolicy .NetworkType .ANY )
3743 .build ());
3844
45+ createNotificationChannel ();
46+
3947 _instance = this ;
4048 }
4149
50+ private void createNotificationChannel () {
51+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
52+ CharSequence name = getString (R .string .channel_name );
53+ String description = getString (R .string .channel_description );
54+ int importance = NotificationManager .IMPORTANCE_DEFAULT ;
55+ NotificationChannel channel = new NotificationChannel (NOTIFICATION_CHANNEL_ID , name , importance );
56+ channel .setDescription (description );
57+ channel .setVibrationPattern (new long []{});
58+ NotificationManager notificationManager = (NotificationManager ) getSystemService (Context .NOTIFICATION_SERVICE );
59+ notificationManager .createNotificationChannel (channel );
60+ }
61+ }
62+
4263 public void runOnMainThread (Runnable runnable ) {
4364 mainThreadHandler .post (runnable );
4465 }
0 commit comments