如何通过从活动到服务的参数? [英] How to pass the parameters to service from an activity?

查看:102
本文介绍了如何通过从活动到服务的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始从活动相关的服务。我打电话通过从活动服务startService(); 。但我想从我的活动有一定的变量在服务code,我在我的活动我调用来使用,所以,请告诉我该怎么做?

Hey , i am starting a service from a activity. I am calling the service from activity by startService();. But i want some variables from my activity to use in the services code which i am invoking in my activity, So please tell me how to do that?

有没有一种方法来传递参数,从调用活动服务?

Is there a way to pass the parameters to service from calling activity?

在此先感谢!

推荐答案

您可以添加的捆绑您的意图(作为一个额外)。
你可以把各种东西(字符串,整数,布尔变量等)的包,并让他们出来以后。

You can add a Bundle to your intent (as an 'extra'). You can put all sorts of stuff (string, ints, bools, etc) in a bundle, and get them out later.

这篇关于如何通过从活动到服务的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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