Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. protected void criarNotificacao(Context context, MensagemAlerta messagesAlerts, Class<?> activity) {
  2.  
  3. NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  4.  
  5. Notification notificaction = new Notification(R.drawable.ic_launcher,
  6. messagesAlerts.getTitle(), System.currentTimeMillis());
  7.  
  8. notificaction.sound = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "6");
  9.  
  10. notificaction.flags |= Notification.FLAG_INSISTENT;
  11.  
  12. notificaction.flags |= Notification.FLAG_AUTO_CANCEL;
  13.  
  14. PendingIntent p = PendingIntent.getActivity(this, 0,
  15. new Intent(this.getApplicationContext(), MyActivity.class), 0);
  16.  
  17. notificaction.setLatestEventInfo(this, messagesAlerts.getSubTitle(),
  18. messagesAlerts.getBody(), p);
  19.  
  20. notificaction.vibrate = new long[] { 100, 1000, 1000, 1000 };
  21.  
  22. notificationManager.notify(R.string.app_name, notificaction);
  23. }
  24.  
  25. public class MensagemAlerta {
  26.  
  27. private CharSequence title;
  28.  
  29. private CharSequence body;
  30.  
  31. private CharSequence subTitle;
  32.  
  33. public MensagemAlerta(CharSequence title, CharSequence body,
  34.  
  35. CharSequence subTitle) {
  36.  
  37. this.title = title;
  38.  
  39. this.body = body;
  40.  
  41. this.subTitle = subTitle;
  42.  
  43. }
  44.  
  45. public CharSequence getTitle() {
  46.  
  47. return title;
  48.  
  49. }
  50.  
  51. public void setTitle(CharSequence title) {
  52.  
  53. this.title = title;
  54.  
  55. }
  56.  
  57. public CharSequence getBody() {
  58.  
  59. return body;
  60.  
  61. }
  62.  
  63. public void setBody(CharSequence body) {
  64.  
  65. this.body = body;
  66.  
  67. }
  68.  
  69. public CharSequence getSubTitle() {
  70.  
  71. return subTitle;
  72.  
  73. }
  74.  
  75. public void setSubTitle(CharSequence subTitle) {
  76.  
  77. this.subTitle = subTitle;
  78.  
  79. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement