Created
February 25, 2016 13:45
-
-
Save maoruibin/1e14da7a29abd2a7bf9d to your computer and use it in GitHub Desktop.
生成一个处于前台状态的通知
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void showNormalNotification(Context context) { | |
NotificationCompat.Builder builder = new NotificationCompat.Builder(context); | |
builder.setContentTitle("Title"); | |
builder.setContentText("Description"); | |
builder.setSmallIcon(R.mipmap.ic_launcher); | |
builder.setPriority(NotificationCompat.PRIORITY_MIN); | |
builder.setOngoing(true); | |
long[] vibrate = {0, 50, 0, 0}; | |
builder.setVibrate(vibrate); | |
Notification notification = builder.build(); | |
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | |
int NOTIFY_ID = 524947901; | |
mNotificationManager.notify(NOTIFY_ID, notification); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment