1 package com
.owncloud
.android
.notifications
;
3 import java
.util
.Random
;
5 import android
.app
.NotificationManager
;
6 import android
.os
.Handler
;
7 import android
.os
.HandlerThread
;
8 import android
.os
.Process
;
10 public class NotificationDelayer
{
12 public static void cancelWithDelay(
13 final NotificationManager notificationManager
,
14 final int notificationId
,
17 HandlerThread thread
= new HandlerThread(
18 "NotificationDelayerThread_" + (new Random(System
.currentTimeMillis())).nextInt(),
19 Process
.THREAD_PRIORITY_BACKGROUND
);
22 Handler handler
= new Handler(thread
.getLooper());
23 handler
.postDelayed(new Runnable() {
25 notificationManager
.cancel(notificationId
);
26 ((HandlerThread
)Thread
.currentThread()).getLooper().quit();