Android Question Fatal Exception: java.lang.RuntimeException: null object reference

PierPaduan

Active Member
Licensed User
Longtime User
Hi everybody.
Crashlytics gave me the following error. It has happened only 3 times on a Nokia 3.1 with Android 9.

The line "service1.java:229" in service1.java should be the following:
B4X:
mostCurrent._service.StartForeground((int) (1),(android.app.Notification)(_vvvvvvvvvvvvvvvvvvvvvvvvvvv0.getObject()));
And it should correspond to the StartForeground line below:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim nNotify As Notification 
End Sub

Sub Service_Create
    nNotify.Initialize
    nNotify.Icon = ""      
    nNotify.Sound=False
    nNotify.Vibrate=False
    nNotify.Light=False
    nNotify.OnGoingEvent=True
    nNotify.SetInfo("", "", "")    
End Sub

Sub Service_Start (StartingIntent As Intent)
    Service.StartForeground(1,nNotify)
    '.......
Am I doing something wrong?
Can someone give to me an advice?
Thanks a Lot.
 

PierPaduan

Active Member
Licensed User
Longtime User
What is causing the service to start?
In this app there is a "Timer" activity that shows a countdown to the user.
If the user put the activity in background, the service starts every second and show to the user a notification with the remaining time.

The service starts from:
  • the "Timer" Activity_Create (but really I don't remember why I decided this years ago, I tried now removing this ServiceStart and all works anyway),
  • the "Timer" Activity_Pause,
  • the Service_Start with a StartServiceAt(... + 1 second ...)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…