From c05f20305b6a33f8dfa46764a5212e5cdf995dc6 Mon Sep 17 00:00:00 2001 From: MOHD NAJIM <40513845+najimali@users.noreply.github.com> Date: Tue, 18 Jun 2019 12:39:52 +0530 Subject: [PATCH] Channel for Oreo support We need to create an channel for oreo support so i create a App.java class & add android:name=".utils.App" in the manifest & pass the channel id in getShareThemNotification()- method -- NotificationCompat.Builder builder = new NotificationCompat.Builder( this,CHANNEL_1_ID); --- App | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 App diff --git a/App b/App new file mode 100644 index 0000000..8af0056 --- /dev/null +++ b/App @@ -0,0 +1,41 @@ +package com.tml.sharethem.utils; + +import android.app.Application; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.os.Build; +import android.util.Log; +import android.widget.Toast; + +import static com.tml.sharethem.sender.SHAREthemActivity.TAG; + +/** + * Created by Nazi on 6/18/2019. + */ + +public class App extends Application { + public static final String CHANNEL_1_ID="channel1"; + + @Override + public void onCreate() { + super.onCreate(); + createNotifcationChannel(); + } + + private void createNotifcationChannel() { + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){ + NotificationChannel channel1 = new NotificationChannel(CHANNEL_1_ID,"CHANNEL 1 ", NotificationManager.IMPORTANCE_HIGH); + NotificationManager manager = getSystemService(NotificationManager.class); + channel1.setDescription("This is Channel 1"); + if(manager!=null) { + manager.createNotificationChannel(channel1); + } + else { + Toast.makeText(this, "Notification Manager is null", Toast.LENGTH_SHORT).show(); + Log.d(TAG, "createNotifcationChannel: null"); + } + } + + + } +}