Pugnotification icon indicating copy to clipboard operation
Pugnotification copied to clipboard

android oreo support(let us know if it's impossible)

Open pourya0111 opened this issue 7 years ago • 2 comments

pourya0111 avatar Dec 19 '17 07:12 pourya0111

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)); }

digitGrove avatar Jan 11 '18 15:01 digitGrove

So it works ?

Zulqurnain avatar Mar 29 '18 08:03 Zulqurnain