普通ならこれでサービスが起動する!はず。
ところが起動してるはずのServiceのonStartCommandが呼ばれない。。。
起動かけてるのはこんなコード。
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent serviceIntent = new Intent(context, MyService.class);
startService(serviceIntent);
}
これ以上ないくらいにシンプルなので、間違いようがないのになんで!?いくら悩んでもわからないので、諦めて就寝。
起きてもう一度Android Studioさんとご対面。
あ!!!!!manifestにService定義がない。
それだけのことでした。
教訓:Service使うときはクラスのひな形作ったらすぐにAndroidManifest.xmlにServiceの定義を書きましょう。