alleviate
alleviate copied to clipboard
Unable to create Service in Java
When I try to create a service by extending ForegroundTaskService
in java at that time I am getting error in android studio.
error: MyForegroundService is not abstract and does not override abstract method onBind(Intent) in Service public class MyForegroundService extends ForegroundTaskService {
'onBind(Intent)' in 'com.rotemati.foregroundsdk.external.services.BaseForegroundTaskService' clashes with 'onBind(Intent)' in 'android.app.Service'; attempting to use incompatible return type
and when I override the OnBind method in my class, it also displays an error.
Kindly advise me on how can I run my code and also provide a full example in JAVA.
My Service Class look like this,
public class MyForegroundService extends ForegroundTaskService {
@Override
public Result doWork() {
return Result.Success;
}
@Override
public Notification getNotification() {
//Display Notification
}
@Override
public Result onStop(StoppedCause stoppedCause) {
return Result.Failed;
}
}
Hi @VT-ChiragBhuva and thanks for pointing this out :) Sorry for not being responsive. To work around this issue, just override the onBind method in your service. In the meantime, I will look into it.