Created
September 26, 2015 18:11
-
-
Save jcguarinpenaranda/6807c174ab4db38350eb to your computer and use it in GitHub Desktop.
Notify in android statusbar method
This file contains 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 notifyStatusBar(String title, String text){ | |
NotificationManager notificationManager = (NotificationManager) | |
getSystemService(NOTIFICATION_SERVICE); | |
Intent intent = new Intent(this, MainActivity.class); | |
PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0); | |
Notification n = new NotificationCompat.Builder(this) | |
.setContentTitle(title) | |
.setContentText(text) | |
.setTicker(text) | |
.setSmallIcon(R.drawable.icon) | |
.setContentIntent(pIntent) | |
.setAutoCancel(true) | |
.build(); | |
notificationManager.notify(0, n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment