簡體   English   中英

無法解析方法OnStartCommand()

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM