public void onStart(Intent intent,int startId)
{
//MainActivity.this.startService(serviceIntent);
super.startService(intent);
// super.onStart(intent, startId);
System.out.println("start Service ,sleep 10 seconds ");
try{
Thread.sleep(10000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
{
//MainActivity.this.startService(serviceIntent);
super.startService(intent);
// super.onStart(intent, startId);
System.out.println("start Service ,sleep 10 seconds ");
try{
Thread.sleep(10000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
Java开发中Service的启动方式
本文详细介绍了在Java开发中使用Service时的启动过程,包括使用startService方法的实现和内部逻辑,以及如何通过Intent参数进行启动。通过实例演示了如何在启动Service时加入延时操作,并对启动过程中可能出现的异常进行了处理。
3万+

被折叠的 条评论
为什么被折叠?



