Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int icon = R.drawable.ic_launcher;
- long when = System.currentTimeMillis();
- Notification notification = new Notification(icon, "Custom Notification", when);
- NotificationManager mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
- RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
- contentView.setImageViewResource(R.id.image, R.drawable.ic_launcher);
- contentView.setTextViewText(R.id.title, "Custom notification");
- contentView.setTextViewText(R.id.text, "This is a custom layout");
- notification.contentView = contentView;
- Intent notificationIntent = new Intent(this, MainActivity.class);
- PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
- notification.contentIntent = contentIntent;
- notification.flags |= Notification.FLAG_NO_CLEAR; //Do not clear the notification
- notification.defaults |= Notification.DEFAULT_LIGHTS; // LED
- notification.defaults |= Notification.DEFAULT_VIBRATE; //Vibration
- notification.defaults |= Notification.DEFAULT_SOUND; // Sound
- mNotificationManager.notify(1, notification);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement