Regarding the problem that service receives the value transmitted by Intent and transmits it after receiving it, ask Great God for help to look at the code.

  java, question

@Override

public void onCreate() {
 new Thread(){
 public void run(){
 try {
 Bundle bundle=tintent.getExtras();
 if (bundle==null) {
 data=1;
 }else {
 data=bundle.getInt("renshu");  //int type passed through in //Activity
 bracket
 
 if (data >= num2) {
 num2=data;
 bracket
 System.out.println(data);
 service=new DatagramSocket(PORT);
 mExecutorService = Executors.newCachedThreadPool();  //Create thread pool
 Socket client = null;
 While (num 2-> = 0) {//listen for client connections
 
 mList.add(client);
 Log.i("TService", "===================>llll");
 byte data [] = new byte[1024];
 packet =new DatagramPacket(data,data.length);
 try {
 service.receive(packet);
 msg=new String(packet.getData(),packet.getOffset(),packet.getLength());
 Log.i("TService", "=============>ooooo");
 Log.i("TService", msg);
 mExecutorService.execute(new Service());
 
 } catch (Exception e) {
 e.printStackTrace();
 bracket
 
 bracket
 
 } catch (Exception e) {
 e.printStackTrace();
 bracket
 bracket
 }.start();
 Log.i("TService ","establishment ");
 super.onCreate();
 bracket
 
 
 @Override
 public void onStart(Intent intent, int startId) {
 
 tintent=intent;
 Log.i("TService ","start ");
 
 handler.postDelayed(runnable, 1000);
 super.onStart(intent, startId);
 bracket

The data is read from other Activity and passed after Editt (the passed value is passed to Thread inside via tintent variable under onstart method). However, when the service is started, the passed value cannot be received. It is said that it is as if you can receive instructions from a great god on how to handle it under the while loop. Ask for advice

Because onCreate is only executed once, startService is always the onStart.