-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
ForegroundServiceDemo crashes with null reference exception when clicking start service #335
Comments
I am seeing the same thing when running the ForegroundServiceDemo in the emulator. |
I found I had to add the FOREGROUND_SERVER permission. The error that is then reported is To get the project to actually build I had to drop the project from Android 12.1 (API 32) down to Android 12.0 (API 31) since API 32 isn't in the Approved List (Recommended) repository. I guess it'll be updated in time. But these demos really should be targeting the Recommended repository. Edit: The remaining error 'Bad notification for startForeground' can be resolved by changing the
|
Issue description
When starting the ForegroundServiceDemo on my Samsung S10 using the Visual Studio debugger attached, it crashes when clicking 'start service'
The exception is a null reference exception with the stack trace:
at Android.Runtime.JNINativeWrapper._unhandled_exception (System.Exception e) [0x0000e] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:12 at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLII_I (_JniMarshal_PPLII_I callback, System.IntPtr jnienv, System.IntPtr klazz, System.IntPtr p0, System.Int32 p1, System.Int32 p2) [0x00022] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:221 at (wrapper native-to-managed) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLII_I(intptr,intptr,intptr,int,int)
The line it fails on is TimeStampService.cs line 155, on the code:
var pendingIntent = PendingIntent.GetActivity(this, 0, notificationIntent, PendingIntentFlags.UpdateCurrent);
Steps to reproduce the issue
What's the expected result?
Service starts
What's the actual result?
Crash
The text was updated successfully, but these errors were encountered: