alleviate icon indicating copy to clipboard operation
alleviate copied to clipboard

Unable to create Service in Java

Open VT-ChiragBhuva opened this issue 2 years ago • 1 comments

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;
    }
}

VT-ChiragBhuva avatar Jul 30 '21 08:07 VT-ChiragBhuva