Closed JorgeHawkins closed 6 years ago
same
The error log has everything you need, IMPORTANCE_LOW is available only from API level 24. So I assume this demo works on only Android 7.x and above.
But still the idea of creating a background service is same for any version. What you write inside depends on your business requirements.
@des-esseintes @JorgeHawkins @manojdcoder the current implementation is using NotificationChannel
and will work only on API 26+ (Android 8 and above). Added in the README
i updated nativescirpt to latest(5.1) Then downloaded project "sample-android-background-services" from github. on click of start notification schedule button was giving this error below. i have nativescript-android-utils installed. can anyone tell me how to solve this ...!
JS: Job Scheduled: 1
JS: Job execution ... System.err: java.lang.RuntimeException: com.tns.NativeScriptException: System.err: Calling js method onStartJob failed System.err: Error: java.lang.NoSuchFieldError: no "I" field "IMPORTANCE_LOW" in class "Landroid/app/NotificationManager;" or its superclasses System.err: com.tns.Runtime.callJSMethodNative(Native Method) System.err: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) System.err: com.tns.Runtime.callJSMethodImpl(Runtime.java:983) System.err: com.tns.Runtime.callJSMethod(Runtime.java:970) System.err: com.tns.Runtime.callJSMethod(Runtime.java:954) System.err: com.tns.Runtime.callJSMethod(Runtime.java:946) System.err: com.tns.notifications.MyJobService.onStartJob(MyJobService.java:18) System.err: android.app.job.JobService$JobHandler.handleMessage(JobService.java:126) System.err: android.os.Handler.dispatchMessage(Handler.java:102) System.err: android.os.Looper.loop(Looper.java:157) System.err: android.app.ActivityThread.main(ActivityThread.java:5601) System.err: java.lang.reflect.Method.invoke(Native Method) System.err: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774) System.err: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) System.err: File: "file:///data/data/org.nativescript.bgservice/files/app/notifications/MyJobService.js, line: 28, column: 59 System.err: StackTrace: System.err: Frame: function:'onStartJob', file:'file:///data/data/org.nativescript.bgservice/files/app/notifications/MyJobService.js', line: 28, column: 60 System.err: at android.app.job.JobService$JobHandler.handleMessage(JobService.java:130) System.err: at android.os.Handler.dispatchMessage(Handler.java:102) System.err: at android.os.Looper.loop(Looper.java:157) System.err: at android.app.ActivityThread.main(ActivityThread.java:5601) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) System.err: Caused by: com.tns.NativeScriptException: System.err: Calling js method onStartJob failed System.err: Error: java.lang.NoSuchFieldError: no "I" field "IMPORTANCE_LOW" in class "Landroid/app/NotificationManager;" or its superclasses System.err: com.tns.Runtime.callJSMethodNative(Native Method) System.err: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) System.err: com.tns.Runtime.callJSMethodImpl(Runtime.java:983) System.err: com.tns.Runtime.callJSMethod(Runtime.java:970) System.err: com.tns.Runtime.callJSMethod(Runtime.java:954) System.err: com.tns.Runtime.callJSMethod(Runtime.java:946) System.err: com.tns.notifications.MyJobService.onStartJob(MyJobService.java:18) System.err: android.app.job.JobService$JobHandler.handleMessage(JobService.java:126) System.err: android.os.Handler.dispatchMessage(Handler.java:102) System.err: android.os.Looper.loop(Looper.java:157) System.err: android.app.ActivityThread.main(ActivityThread.java:5601) System.err: java.lang.reflect.Method.invoke(Native Method) System.err: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774) System.err: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) System.err: File: "file:///data/data/org.nativescript.bgservice/files/app/notifications/MyJobService.js, line: 28, column: 59 System.err: StackTrace: System.err: Frame: function:'onStartJob', file:'file:///data/data/org.nativescript.bgservice/files/app/notifications/MyJobService.js', line: 28, column: 60 System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:983) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:970) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:954) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:946) System.err: at com.tns.notifications.MyJobService.onStartJob(MyJobService.java:18) System.err: at android.app.job.JobService$JobHandler.handleMessage(JobService.java:126) System.err: ... 6 more System.err: Caused by: java.lang.NoSuchFieldError: no "I" field "IMPORTANCE_LOW" in class "Landroid/app/NotificationManager;" or its superclasses System.err: ... 14 more
While trying to run the demo in my 5.1.1 phone, I managed to get this error: