Android: stopService doesn't call onDestroy

前端 未结 4 1848
北恋
北恋 2020-12-11 01:13

I have big problems with stopping a service, which plays audio file. I want to stop the current service before I play another file.

Activity:

public vo         


        
4条回答
  •  没有蜡笔的小新
    2020-12-11 01:34

    First, it's onDestroy, not OnDestroy . Second, you must use the @Override annotation for compile-time checking, so your Service code should look somewhat like this:

    @Override
    public void onDestroy(){
        Log.v("SERVICE","Service killed");
        player.stop();
        super.onDestroy();  
    }
    

提交回复
热议问题