Android Question Service.StartForeground change strings

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi, Im using Service.StartForeground in my service.
As noted in the other Threads I code:

B4X:
    snotif.Initialize
    snotif.Icon = "logo.png"
    snotif.SetInfo2("TITLE","SUB_TITLE",0,mDashboard)
    snotif.Sound = False
    snotif.Notify(1)
    Service.StartForeground(1,snotif)

And there are two weird results.

-When the service is started, the icon is OK but the "TITLE" is replaced by the app name and the "SUB_TITLE" by "Touch to obtain more information..." and if you touch you are redirected to the Android app form from where you can Stop and Unistall and etc...

-The other weird behavior is that when you lunch a real notification from your app these initial service notification is replaced by the new notification, it works ok touching it and going to the activity I want but... stays with the title and subtitle of the last notification and cant be deleted from the notification pad. Then been confusing to the user.

Tested using SetInfo and Setinfo2

Am I doing somethig wrong? Android 4.3
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
1- I delete the snotif.Notify and nothig changes, still replacing Title and Subtitle and going to the Stop-Unistall Android page.
2- All my notification has its own ID

FWIW Im doing this in the first line of Service_Create

I've added this lines to the begginig of the Service_Start, trying to reproduce the problem 2 and then fix the title and subtitle:

B4X:
    Dim snot As Notification
    snot.Initialize
    snot.Icon = "logo.png"
    snot.Sound = False
    snot.Vibrate = False
    snot.SetInfo2("PortIt","Servicio de Lectura",0,mDashboard)
    snot.Notify(1)

And the result is the Notification is gone!!

All subsecuent notification works ok.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi, now Im having problems with

B4X:
 snot.SetInfo2("PortIt","Servicio de Lectura",0,mDashboard)

mDashboard is the 2nd activity that is called by Main when the app starts, the app never comes back to Main.
If I use this code when I use the app and goes back and forth into the app activities, if I click in the notification sometimes it does not works well, it crashes or loose variables..
If I code like

B4X:
 snot.SetInfo2("PortIt","Servicio de Lectura",0,"")

nothing happesn and all is ok

Is the any thing I can replace mDashboard to make the app to open in the actual activity?

Thanks
 
Upvote 0
Top