Android Question Force Notification

Pooya1

Active Member
Licensed User
Hi
Sometimes when my app is background and after example a day back to app,show notification in status bar that i cannot close it and i have to restart device for remove it
I use notification in app when i receive new data from b4j socket
I use NB6
The shot is attachment here

B4X:
        Dim notify As NB6
        notify.Initialize("default","HOTEL","DEFAULT")
        notify.AutoCancel(True).SetDefaults(True,True,True)
        notify.AddButtonAction(Null,"Reply",Loader,"new_message_" & user_id)
        
        Dim ph As Phone
        If ph.SdkVersion >= 22 Then
            notify.SmallIcon(LoadBitmapResize(File.DirAssets,"notification_icon_white.png",40dip,40dip,True))
        Else
            notify.SmallIcon(LoadBitmapResize(File.DirAssets,"notification_icon_color.png",40dip,40dip,True))
        End If
        
        notify.LargeIcon(LoadBitmapResize(File.DirAssets,"notification_icon_color.png",46dip,46dip,True))
        notify.BigTextStyle(user_name,"",content)
        notify.Build(user_name,content,message_object.Get("user_id"),Main).Notify(user_id)
 

Attachments

  • photo_2018-06-25_11-40-32.jpg
    photo_2018-06-25_11-40-32.jpg
    34 KB · Views: 228

Pooya1

Active Member
Licensed User
Are you calling Service.StopAutomaticForeground?
No because i use b4j socket server that listen to server and should not close this service,isn't it?
When i remove notification codes from app,again i see this notification:|
 
Upvote 0

Pooya1

Active Member
Licensed User
Problem was solved
I used
Sub Service_Start (StartingIntent As Intent)
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS 'Call this when the background task completes (If there Is one)
End Sub in my service
and when i removed it,problem solved
But i need service be active for always for use b4j server :(
 
Upvote 0
Top