android service怎么判断是自己关的还是系统关的

2025-05-11 09:12:29
推荐回答(1个)
回答1:

 启动:
  //首先注册服务
    android:name="com.wangdeyu.service.MusicService"
  android:exported="false" >
  
  
  

  
  
  //启动服务
  Intent service=new Intent(" com.abc");
  startService(service);
  //Service生命周期
  ①onCreate() 创建Service
  ②onStart(Intent intent, int startId) 启动Service
  ③onDestroy() 销毁Service
  //关闭服务
  stopService(service);