Issue: since I now need to target Oreo to submit apps, I have to change my RegistrationIntentService to inherit from JobIntentService instead of IntentService. I am still using GCM, but that should make no difference. Note that this is Xamarin C# code.
The error is that I always get an exception in my static EnqueueWork method saying:
Scheduled service ComponentInfo{com.emergencyuniversity.EUAlert/md58d0653b4094c2dbc798f6d984e1c1386.RegistrationIntentService} does not require android.permission.BIND_JOB_SERVICE permission
I've changed OnHandleIntent to OnHandleWork, and I now call the static EnqueueWork convenience method in places where I used to call StartService.
var intent = new Intent (this, typeof (RegistrationIntentService));
RegistrationIntentService.EnqueueWork(this, intent); // instead of StartService(intent)
My EnqueueWork, that gets the exception:
public static void EnqueueWork(Context context, Intent work)
{
Java.Lang.Class cls = Java.Lang.Class.FromType(typeof(RegistrationIntentService));
try
{
EnqueueWork(context, cls, GCMEUA_JOB_ID, work);
}
catch (Exception ex)
{
Console.WriteLine("Exception: {0}", ex.Message);
}
}
In the manifest, I added:
<service android:name=".RegistrationIntentService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" />
I've also tried exported false, and putting that permission in a bunch of different places.
One other change I made was removing the following due to compiler errors:
public RegistrationIntentService() : base("RegistrationIntentService") { }
In addition to the Android docs, I have probably read every post imaginable about this, including:
https://medium.com/til-kotlin/jobintentservice-for-background-processing-on-android-o-39535460e060
JobService does not require android.permission.BIND_JOB_SERVICE permission
Why do I still get this error? Any help would be greatly appreciated. Thanks.