[英]Cannot resolve method OnStartCommand()
我正在嘗試在android API 22中創建服務。嘗試覆蓋方法OnStartCommand()時出現錯誤。 “ 無法解析方法 ”。 當我不重寫該方法時,出現錯誤' 方法不重寫超類的方法 '。 我正在使用Android Studio 1.5.1
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class BlockService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void OnStartCommand(Intent intent,int flags, int startId){
Toast.makeText(this,"service Started",Toast.LENGTH_LONG).show();
}
}
Java區分大小寫。 方法名稱是onStartCommand()
,而不是OnStartCommand()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.