A
A
Alexander2015-02-25 11:04:12
Android
Alexander, 2015-02-25 11:04:12

How to create a notification service on Android?

There is an application that should send notifications. It was written in Qt, but the problem itself, it seems to me, is buried in Java or in the manifest. In general, using this script, I managed to fasten the notifications that are sent from the service (class QtService ).
I built the queue and check of notifications in this way: when the Activity is first launched, a list is sent to the class (QtService) at what time this or that notification should be displayed. In the onCreate() method of this class, a timer (Timer) is started that fires every minute and calls the timerTick() method - in this method I compare the current system time and check which notification from the list should be shown. ( In my gut I feel that I did everything wrong: D )
So, notifications come regularly and at the appointed time, BUT! Only if the application itself is running, i.e. there is an Activity and it is either active or minimized and hangs in tasks. As soon as the activity closes, notifications stop coming, although the service itself is present in the list of running applications (Processes: 1; services: 1). CHADNT?
Why is that? After all, the service is running. What happens when the application closes? Destroying timers? Or it is impossible to call NotificationManager'a methods from timers?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question