I'm developing an alarm app that uses a background service and I'd like an activity (module or page) to open when the alarm goes off. I searched the forum and found that StartActivity cannot be used with the background service unless it has a permission to draw on top of other applications. Well, I used that permission, but it still gives an error. The error is as follows:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference
I tested it in release mode and the error log is pretty much the same!
Error occurred on line: 15 (B4XPages)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference
at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.CreatePanel(B4XViewWrapper.java:771)
at b4a.example3.customlistview._createpanel(customlistview.java:239)
at b4a.example3.customlistview._insertattextitem(customlistview.java:699)
at b4a.example3.customlistview._addtextitem(customlistview.java:78)
at Agenda.example.alarme$ResumableSub_Service_Start.resume(alarme.java:554)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I managed to make it work. It is now opening the MainPage for me to place a mgbox there. However, I can only open MainPage with StartActivity. Could I open other modules besides MainPage?
As for Service_Start, I'm using it to manage my alarms, that's all. Or have you detected something wrong that I could be doing?