0

我想从 1 个活动启动两个服务并同时运行所有 3 个东西

`

     @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    gpsManager = new GPSManager();

    gpsManager.startListening(getApplicationContext());
    gpsManager.setGPSCallback(this);
    Toast.makeText(this, "after GPS Manager", 2000).show();

    ((TextView)findViewById(R.id.info_message)).setText(getString(R.string.info));

    measurement_index = AppSettings.getMeasureUnit(this);
    Intent i=getIntent();
     number=i.getStringExtra("NUMBER");


     Intent spl=new Intent(GPS2Activity.this,SPLService.class);
     spl.putExtra("NUMBER", number);
     startService(spl);

     Intent gforce=new Intent(GPS2Activity.this,GforceService.class);
     gforce.putExtra("NUMBER", number);
     startService(gforce);




     Toast.makeText(this, "complete on create", 2000).show();





}`

但任何服务都没有启动。这种方式有什么不对吗?或者从同一活动启动 2 个服务以同时运行的其他可能方法是什么

谢谢你

4

0 回答 0