Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Null Pointer Exception #129

Closed

Conversation

sofronovicnikola
Copy link

Fixes #127

Issue is reproducible when service/process is potentially killed by the system and since ScreenRecordingService.onStartCommand() is returning START_STICKY, and if the service is in the started state, system will try to recreate the service. But, it will not retain intent. So, intent will be null in that case and
Attempt to invoke virtual method 'long android.content.Intent.getLongExtra(java.lang.String, long)' on a null object reference will occur.

In that case, stopping service is called to avoid any other potential issue.

Also, consider returning START_REDELIVER_INTENT instead of START_STICKY, so Intent is retained after a service restart.

Changes:

Added null check on Intent
Stop Service if Intent is null

@bomberaya
Copy link

@HBiSoft have you had the chance to look at this?

@imoralesIncode
Copy link

Hi, do you have opportunity to include the fix on the library?

@HBiSoft
Copy link
Owner

HBiSoft commented Dec 2, 2022

My sincerest apologies for the delay in response. I was busy with a big project. I will quickly look at this and merge it if everything looks ok

@vivek-mittal
Copy link

Hi, @HBiSoft -
Any plans to merge this PR? I am also seeing the following issue frequently -
java.lang.RuntimeException: Unable to start service com.hbisoft.hbrecorder.ScreenRecordService@a88bce with null: java.lang.NullPointerException: Attempt to invoke virtual method 'long android.content.Intent.getLongExtra(java.lang.String, long)' on a null object reference

@HBiSoft
Copy link
Owner

HBiSoft commented Mar 5, 2023

This is now implemented in - https://github.com/HBiSoft/HBRecorder/releases/tag/2.0.6

Thank you for this and apologies for waiting so long to implement this.

@HBiSoft HBiSoft closed this Mar 5, 2023
@HBiSoft
Copy link
Owner

HBiSoft commented Mar 6, 2023

Just a note, there was an issue with the previous release caused by updating the dependencies, not sure if you noticed it.
I have updated the library again - https://github.com/HBiSoft/HBRecorder/releases/tag/3.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Caused by java.lang.NullPointerException
5 participants