Comments (2)
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));
}
from pugnotification.
So it works ?
from pugnotification.
Related Issues (20)
- Context being leaked?
- Support Android Nīŧ
- How to pass a parameter isVibrate and isSound ?
- Notification progress update error HOT 2
- Use .flags(Notification.DEFAULT_ALL) without vibrate and sound
- Proguard issue even after adding -dontwarn com.squareup.okhttp.**
- Please show more example
- Ticker not showing
- Bundle not sending if activity is open HOT 1
- Wish to add a download sample
- Support for Android O
- Android 8 HOT 2
- How can I cancel notification by PENDING_INTENT_ID
- Vibrate with prefrence Screen
- android o I won't support it
- Image Loading with Glide
- java.lang.IllegalStateException: Method call should happen from the main thread
- Is this library still managed ? HOT 1
- can you schedule notifications to a specific time?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pugnotification.