Pugnotification
Pugnotification copied to clipboard
android oreo support(let us know if it's impossible)
I have a solution
1.) Add NotificationUtils.java
package br.com.goncalves.pugnotification.notification;
/**
- Created by EZHIL on 1/11/2018. */
import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.content.ContextWrapper; import android.graphics.Color; import android.os.Build;
public class NotificationUtils extends ContextWrapper {
private NotificationManager mManager;
public static final String CHANNEL_ID = "YOUR_CHANNEL_ID";
public static final String CHANNEL_NAME = "YOUR_CHANNEL_NAME";
public NotificationUtils(Context base) {
super(base);
createChannels();
}
public void createChannels() {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// create android channel
NotificationChannel androidChannel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
// Sets whether notifications posted to this channel should display notification lights
androidChannel.enableLights(true);
// Sets whether notification posted to this channel should vibrate.
androidChannel.enableVibration(true);
// Sets the notification light color for notifications posted to this channel
androidChannel.setLightColor(Color.BLUE);
// Sets whether notifications posted to this channel appear on the lockscreen or not
androidChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
getManager().createNotificationChannel(androidChannel);
}
}catch (Exception e){
e.printStackTrace();
}
}
private NotificationManager getManager() {
if (mManager == null) {
mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
return mManager;
}
}
2.) make this change in Load.java
public Load() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { try { NotificationUtils notificationUtils = new NotificationUtils(PugNotification.mSingleton.mContext); builder = new NotificationCompat.Builder(PugNotification.mSingleton.mContext, NotificationUtils.CHANNEL_ID); }catch (Exception e){ e.printStackTrace(); } }else { builder = new NotificationCompat.Builder(PugNotification.mSingleton.mContext); } builder.setContentIntent(PendingIntent.getBroadcast(PugNotification.mSingleton.mContext, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT)); }
So it works ?