Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void criarNotificacao(Context context, MensagemAlerta messagesAlerts, Class<?> activity) {
- NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- Notification notificaction = new Notification(R.drawable.ic_launcher,
- messagesAlerts.getTitle(), System.currentTimeMillis());
- notificaction.sound = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "6");
- notificaction.flags |= Notification.FLAG_INSISTENT;
- notificaction.flags |= Notification.FLAG_AUTO_CANCEL;
- PendingIntent p = PendingIntent.getActivity(this, 0,
- new Intent(this.getApplicationContext(), MyActivity.class), 0);
- notificaction.setLatestEventInfo(this, messagesAlerts.getSubTitle(),
- messagesAlerts.getBody(), p);
- notificaction.vibrate = new long[] { 100, 1000, 1000, 1000 };
- notificationManager.notify(R.string.app_name, notificaction);
- }
- public class MensagemAlerta {
- private CharSequence title;
- private CharSequence body;
- private CharSequence subTitle;
- public MensagemAlerta(CharSequence title, CharSequence body,
- CharSequence subTitle) {
- this.title = title;
- this.body = body;
- this.subTitle = subTitle;
- }
- public CharSequence getTitle() {
- return title;
- }
- public void setTitle(CharSequence title) {
- this.title = title;
- }
- public CharSequence getBody() {
- return body;
- }
- public void setBody(CharSequence body) {
- this.body = body;
- }
- public CharSequence getSubTitle() {
- return subTitle;
- }
- public void setSubTitle(CharSequence subTitle) {
- this.subTitle = subTitle;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement