杀不死的服务

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, Service1.class);
startService(intent);
}
}

 


public class Service1 extends Service {

@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}

@Override
public void onCreate() {
super.onCreate();
}

@Override
public void onDestroy() {
Intent intent = new Intent(this,Service2.class);
startService(intent);
super.onDestroy();
}


}

 

 

public class Service2 extends Service {

@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}

@Override
public void onDestroy() {
Intent intent = new Intent(this,Service1.class);
startService(intent);
super.onDestroy();
}

}

posted @ 2015-11-30 16:47  黑土白云  阅读(156)  评论(0编辑  收藏  举报