Guest User

Untitled

a guest
Jul 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public int noti(String title, String body, String ico){
  2. //Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
  3. showToast(title+">"+body+">"+ico);
  4. try{
  5. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com/"));
  6. PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
  7. Notification.Builder mBuilder =
  8. new Notification.Builder(getApplicationContext(), "83")
  9. .setSmallIcon(Icon.createWithContentUri(ico))
  10. .setContentTitle(title)
  11. .setContentText(body)
  12. .setOngoing(true)
  13. .setContentIntent(pendingIntent)
  14. .setPriority(NotificationCompat.PRIORITY_DEFAULT);
  15. NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getApplicationContext());
  16. Notification noti = mBuilder.build();
  17. if(noti==null){
  18. logBack("noti.builder == null.");
  19. return -2;
  20. }
  21. int notificationId = notiIDz.getAndIncrement();
  22. // notificationId is a unique int for each notification that you must define
  23. notificationManager.notify(notificationId, noti);
  24. return notificationId;
  25. } catch(Exception e){
  26. logBack(e.toString());
  27. }
  28. return -1;
Add Comment
Please, Sign In to add comment