Android Question [Solved] Notification don't work in Android 6.0 (works in 4.0, 4.4, 7.0). SDK = 26.

asales

Expert
Licensed User
Longtime User
I use this code below to notification and now I will update the app to SDK = 26.
The notification was works fine before, but now works only in Android 4, 4.4 and 7.0.

I tried with others codes from the forum and NB6 Class without success.

Any tip are welcome to solved this problem.

Thanks in advance.

Alarm Service:
B4X:
#Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals
End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
    Dim n As Notification
    n.Initialize
    n.Icon = "icon"
    n.AutoCancel = True
    n.SetInfo2("Title", "Content", "odNotify", Main)
    n.Notify(1)
    
    Dim t As Long
    t = FindNextTime(Array As Double(10, 18, 22)
    
    StartServiceAt(Me,t,True)
    StopService("")
End Sub

Main module:
B4X:
Sub StartNotification
    Dim t As Long
    t = FindNextTime(Array As Double(10, 18, 22)
    
    Starter.manager.SetBoolean("alarm", True)

    CancelScheduledService(Alarm)
    StartServiceAt(Alarm,t,True)
End Sub
 

asales

Expert
Licensed User
Longtime User
Tip: Better to write StopService(Me) instead of StopService("").
OK
Also make sure that this is not the starter service. The starter service should never be started with StartServiceAt.
The Alarm Service is another service. Not the Starter.
As a test change the package name and try it again.
I uninstalled the app from device, created a fresh instalation and it works (for now).

Thanks!
 
Upvote 0
Top