Android Question Service Bad notification startForeground

Discussion in 'Android Questions' started by imgsimonebiliato, Jul 8, 2015.

  1. imgsimonebiliato

    imgsimonebiliato Well-Known Member Licensed User

    Hello,
    I create a service that works foreground.

    Code:
    Sub Process_Globals
    Dim sNotif As Notification
    End Sub

    Sub Service_Create
    sNotif.Initialize
    Service.StartForeground(1, sNotif)
    End Sub
    When I start the application, I've got this log error.
    What's wrong?


    Code:
    ** Activity (main) Create, isFirst = true **


    --
    Service Started--
    ** 
    Service (sinventario) Start **

    Start 
    Service
    ** 
    Activity (main) Pause, UserClosed = true **

    android.app.RemoteServiceException: Bad 
    notification for startForeground: java.lang.RuntimeException: icon must be non-zero

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:
    1488)
        at android.os.Handler.dispatchMessage(Handler.java:
    110)
        at android.os.Looper.loop(Looper.java:
    193)
        at android.app.ActivityThread.main(ActivityThread.java:
    5292)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:
    515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:
    824)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    640)
        at dalvik.system.NativeStart.main(Native Method)
     
  2. sonicmayne

    sonicmayne Member Licensed User

    You have initialized the notification, but as the exception says you haven't set an icon for it.

    If you just want to the use app's default icon use:
    Code:
    sNotif.Iccon = "icon"
    Also you haven't called SetInfo or SetInfo2, are you sure you want to display no text to the user?
     
    imgsimonebiliato likes this.
  3. imgsimonebiliato

    imgsimonebiliato Well-Known Member Licensed User

    If it is possible, I don't want also to display the notification
     
  4. imgsimonebiliato

    imgsimonebiliato Well-Known Member Licensed User

    After I add:
    Code:
    sNotif.SetInfo("""", Main)
    sNotif.Icon = 
    "icon"
    The app works.

    Thanks
     
    sonicmayne likes this.
Loading...