android服务类中的错误

维斯瓦吉斯

我在服务类别中收到以下错误。这是什么问题?

错误:(17,8)错误:NotificationService不是抽象的,并且不会覆盖Service中的抽象方法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);
    }
}
哈迪·萨特里奥(Hadi Satrio)

该错误向您清楚地说明了这一点:您必须重写onBind()或以其他方式使服务抽象化。

这是您应该如何做:

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章