Created
December 11, 2014 11:21
-
-
Save ionull/d0b59da8a6bd6ed29d24 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
// Post a notification indicating whether a doodle was found. | |
private void sendNotification(String msg, Bundle bundle) { | |
mNotificationManager = (NotificationManager) | |
this.getSystemService(Context.NOTIFICATION_SERVICE); | |
Intent intent = new Intent(this, NotificationActivity.class); | |
intent.putExtras(bundle); | |
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, | |
intent, 0); | |
NotificationCompat.Builder mBuilder = | |
new NotificationCompat.Builder(this) | |
.setSmallIcon(R.drawable.ic_logo) | |
.setContentTitle(getString(R.string.title_new_notification)) | |
.setStyle(new NotificationCompat.BigTextStyle() | |
.bigText(msg)) | |
.setContentText(msg); | |
mBuilder.setContentIntent(contentIntent); | |
android.app.Notification notification = mBuilder.build(); | |
if (NotificationUtils.isVibrateEnable(this)) { | |
notification.defaults |= android.app.Notification.DEFAULT_VIBRATE; | |
} | |
String ringtone = NotificationUtils.getRingtone(this); | |
if (!NotificationUtils.isSilent(ringtone)) { | |
if (NotificationUtils.isDefaultRingtone(ringtone)) { | |
notification.defaults |= android.app.Notification.DEFAULT_SOUND; | |
} else { | |
notification.sound = Uri.parse(ringtone); | |
} | |
} | |
mNotificationManager.notify(NOTIFICATION_ID, notification); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment