Closed johng1492 closed 2 years ago
I understand you are getting an error based on a change you made to the original code, the current code does not throw any kind of error. I suggest you go throw the documentation of Messaging Center: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/messaging-center
Describe the bug When trying to start location service, in foreground, on Android, I get the error: Bad notification posted from package com.xxx.xxxxxxx: Couldn't create icon: StatusBarIcon(.
The issue is on starting the service and I have tried for hours on what the issue is. I think it's a NULL that I'm passing someplace that is expecting a value.
To Reproduce Steps to reproduce the behavior:
Call: MessagingCenter.Send(message, "ServiceStarted"); from FORMS
Here is the method (same as your sample): MessagingCenter.Subscribe(this, "ServiceStarted", message => {
if (!IsServiceRunning(typeof(AndroidLocationService)))
{
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
{
StartForegroundService(serviceIntent);
}
else
{
StartService(serviceIntent);
}
}
});
Here is the LocationService StartCommand: public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { _cts = new CancellationTokenSource();
It seems like it bombs on: locShared.Run(_cts.Token).Wait(); above.
Expected behavior To start the location service and track the user's location
Smartphone (please complete the following information):