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 manifests 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 aBroadcastReceiverto use withAlarmManager) to handle it for them. They will have to register that component, as you note.Not really. If the process is terminated during your time window, your thread is terminated along with it.