开发者

Android Notification timeout without using a service

开发者 https://www.devze.com 2023-03-07 03:34 出处:网络
I\'m developing a common library (external jar) that is being provided to different developers of android apps.

I'm developing a common library (external jar) that is being provided to different developers of android apps.

I have a function that will display a Notification.

I want to have the notification timeout after 30-90 seconds

I want to minimize the requirements for the app developers, so writing a common service, and having them adding it to their manif开发者_如何学编程ests is my least favorite option.

Is it safe to spawn a thread and keep a handle to the notification manager?

Is there a better way to do this?


Either let the developer handle the dismissal/update themselves, or you will have to supply some sort of component (Service, or a BroadcastReceiver to use with AlarmManager) to handle it for them. They will have to register that component, as you note.

Is it safe to spawn a thread and keep a handle to the notification manager?

Not really. If the process is terminated during your time window, your thread is terminated along with it.

0

精彩评论

暂无评论...
验证码 换一张
取 消