Skip to content

Unable to create Service in Java #3

@VT-ChiragBhuva

Description

@VT-ChiragBhuva

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions