Advertisement
arter97

Untitled

Mar 29th, 2017
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public static void threadTest(Context context, String s) {
  2. Runnable cu = new threadTestClass(context, s);
  3. Thread cuThread = new Thread(cu);
  4. cuThread.start();
  5. }
  6.  
  7. private static class threadTestClass implements Runnable {
  8. private final Context context;
  9. private final String str;
  10.  
  11. public threadTestClass(Context cont, String s) {
  12. context = cont;
  13. str = s;
  14. }
  15.  
  16. public void run() {
  17. NotificationManager mNotifyManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
  18. Notification.Builder nBuilder = new Notification.Builder(context);
  19.  
  20. nBuilder.setContentTitle("IGRUS!");
  21. nBuilder.setContentText(str);
  22. nBuilder.setSmallIcon(R.mipmap.ic_launcher);
  23. nBuilder.setOngoing(false);
  24. nBuilder.setProgress(100, 1, true);
  25.  
  26. for (int i = 1; i < 10; i++) {
  27. mNotifyManager.notify(i, nBuilder.build());
  28.  
  29. try {
  30. Thread.sleep(1000);
  31. } catch (Exception e) {
  32. //
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement