Hi,
I have been to have a notification icon in my service.
I tried both the default Notification as well as the CustomNotification (http://www.b4x.com/android/forum/threads/custom-notification-library-barx.16950/)
The second works on an emulator but crashes on my Galaxy S3.
This is an example of the default notification
On my Galaxy S3 I get following exception when the Service is started
** Service (svcmain) Create **
** Service (svcmain) Create **
** Service (svcmain) Start **
** Service (svcmain) Start **
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.IllegalArgumentException: contentView required: pkg=b4a.example id=1 notification=Notification(pri=0 contentView=null vibrate=default sound=default defaults=0xffffffff flags=0x50 kind=[null]) tickerText=null contactCharSeq=null when=1377029474251 threadId=0
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.IllegalArgumentException: contentView required: pkg=b4a.example id=1 notification=Notification(pri=0 contentView=null vibrate=default sound=default defaults=0xffffffff flags=0x50 kind=[null]) tickerText=null contactCharSeq=null when=1377029474251 threadId=0
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Thank you !!
I have been to have a notification icon in my service.
I tried both the default Notification as well as the CustomNotification (http://www.b4x.com/android/forum/threads/custom-notification-library-barx.16950/)
The second works on an emulator but crashes on my Galaxy S3.
This is an example of the default notification
B4X:
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
Dim ntf As Notification
End Sub
Sub Service_Create
ntf.Initialize
ntf.Icon = "icon"
ntf.AutoCancel = True
ntf.Vibrate = True
ntf.Light = True
ntf.Sound = True
ntf.SetInfo ("foo", "foo", Main)
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground(1, ntf)
End Sub
Sub pc_CountersRead (p1Counter As Int, p2Counter As Int)
ntf.Number = 11 'just demo
ntf.Notify(1)
End Sub
On my Galaxy S3 I get following exception when the Service is started
** Service (svcmain) Create **
** Service (svcmain) Create **
** Service (svcmain) Start **
** Service (svcmain) Start **
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.IllegalArgumentException: contentView required: pkg=b4a.example id=1 notification=Notification(pri=0 contentView=null vibrate=default sound=default defaults=0xffffffff flags=0x50 kind=[null]) tickerText=null contactCharSeq=null when=1377029474251 threadId=0
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.IllegalArgumentException: contentView required: pkg=b4a.example id=1 notification=Notification(pri=0 contentView=null vibrate=default sound=default defaults=0xffffffff flags=0x50 kind=[null]) tickerText=null contactCharSeq=null when=1377029474251 threadId=0
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Thank you !!