Created
May 16, 2017 08:48
-
-
Save donrokzon/53321ad4800192fe80709859cc810906 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
| NotificationManager manager; | |
| private void createNotification() { | |
| NotificationCompat.Builder mBuilder = | |
| new NotificationCompat.Builder(this) | |
| .setSmallIcon(R.drawable.notification) | |
| .setContentTitle("My notification") | |
| .setOngoing(true) | |
| .setContentText("Hello World!"); | |
| Intent notificationIntent = new Intent(this, MainActivity.class); | |
| PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, | |
| PendingIntent.FLAG_UPDATE_CURRENT); | |
| mBuilder.setContentIntent(contentIntent); | |
| manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | |
| manager.notify(0, mBuilder.build()); | |
| } | |
| void cancelNot(){ | |
| manager.cancel(0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment