android 服务 class 出错

Error in android service class

我在服务 class 中收到以下错误。这里有什么问题?

错误:(17, 8) 错误:NotificationService 不是抽象的,不会覆盖服务中的抽象方法 onBind(Intent)

这是我的代码:

package works.viswajith.birthdayreminder;

import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.support.v4.app.NotificationCompat;


import java.util.Calendar;

/**
 * Created by Viswajith on 6/17/2015.
 */
public class NotificationService extends Service {

   DBHelper db;
   private Cursor cur;
   private Calendar cal;
   private int d,m,y;
   private String[] temp;
   private NotificationManager nm;
   int i=0;


    @Override
    public void onCreate() {
        super.onCreate();

        db=new DBHelper(getApplicationContext());
        cur=db.getDetails();
        cal= Calendar.getInstance();
        d=cal.get(Calendar.DAY_OF_MONTH);
        m=cal.get(Calendar.MONTH);
        y=cal.get(Calendar.YEAR);

    }


    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        for(i=0;i<db.getCount();i++)
        {
           temp=cur.getString(2).split("/");
            if(Integer.parseInt(temp[0])==d)
            {

                NotificationCompat.Builder mbuilder=new NotificationCompat.Builder(this);
                mbuilder.setSmallIcon(R.drawable.happy);
                mbuilder.setContentTitle("Happy B'day "+cur.getString(0));
                mbuilder.setContentText("Today is "+cur.getString(0)+"'s B'day , Wish him ..");
                nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                nm.notify(100,mbuilder.build());


            }

            cur.moveToNext();

        }

        return super.onStartCommand(intent, flags, startId);
    }
}

错误已经向您解释得非常清楚:您必须覆盖 onBind() 或以其他方式使您的服务抽象化。

您应该这样做:

@Override
public IBinder onBind(Intent intent) {
   // Implement your logic here.
}

它准确地告诉您需要做什么...

因为你正在扩展一个服务,所以你需要覆盖onBind方法。

将以下内容添加到您的class:

@Override
public IBinder onBind(Intent intent) {
}

当 android 绑定到您的服务时将调用此方法。