可以从同一活动启动2服务,并且可以在Android的parrallely运行的活性和两个服务? [英] Can start 2 services from the same activity and can run that activity and two services parrallely in android?

查看:121
本文介绍了可以从同一活动启动2服务,并且可以在Android的parrallely运行的活性和两个服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个服务,以获得来自加速度计和麦克风和1的活动数据来获得GPS数据。欲同时运行这些三件事。我想知道的是,有可能在Android系统。而GPS活动运行并显示在用户界面中的数据,其他2个服务ALSE应该在后台运行。

I have 2 services to get data from the accelerometer and microphone and 1 activity to get GPS data. I want to run these 3 things at the same time. I want to know is that possible in Android. While the GPS Activity running and display the data on the UI, other 2 services alse should run in the background.

如果有可能的方式是正确的,我给从我的GPS Activity类启动两项服务,并在同一时间运行的3件事。请任何一个HLP我。谢谢你。

If it is possible is the way correct that I gave to start two services from my GPS Activity class and run those 3 thing at the same time. Please any one hlp me. Thank you.

`

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


    gpsManager = new GPSManager();

    gpsManager.startListening(getApplicationContext());
    gpsManager.setGPSCallback(this);

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

    measurement_index = AppSettings.getMeasureUnit(this);
    Intent i=getIntent();
     number=i.getStringExtra("NUMBER");
     startService(new Intent(GPS2Activity.this, GforceService.class));
     startService(new Intent(GPS2Activity.this,SPLService.class));



} `

GforceService SPLService 是我的2服务

推荐答案

是的,你就可以开始2服务,并让他们在与平行的活动运行。

Yes, you can start 2 services and have them running in parallel with your Activities.

这篇关于可以从同一活动启动2服务,并且可以在Android的parrallely运行的活性和两个服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆