启动远程服务,并获得结果的Andr​​oid [英] start a remote service and receive a result in Android

查看:144
本文介绍了启动远程服务,并获得结果的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个应用程序。 一个应用程序有活动,另一个是后台服务。

I have two applications. One app has the Activity and another one is a background service.

我也能够使用隐式意图过滤器从我的活动应用程序访问该服务的应用程序。

I can able to access the service app from my activity app using implicit intent filters.

我需要从服务获得的结果。

I need to receive a result from the service.

有关EX:

从活动的应用程序,我准备启动该服务,并发送数据。 在服务应用程序,我需要接收数据,并做一些检查,需要返回到活动的应用程序的修改后的结果。

From activity app, i am going to start the service and send a data. In the service app, i need to receive the data and do some inspections and need to return to the activity app as modified result.

我可以通过发送 putExtra 和能能够通过 getExtra 检索它的服务。我需要从服务中返回一个值,并接受它的活动应用程序。

I can able to send by putExtra and can able to retrieve it in the service by getExtra. I need to return a value from service and receive it in activity app.

PS:我需要的是,以同样的方式我们做什么用完成() onActivityResult()替换活动结果

PS: The thing i needed is, the same way what we do with finish() and onActivityResult() with the Activity results.

在此先感谢你的主人......

Thanks in advance to you masters...

推荐答案

为什么要通过意图进行沟通,同时有一个完美的工作粘结剂协议。

Why do you want to communicate through intent while there is a perfectly working binder protocol.

http://developer.android.com/guide/topics/基本面/束缚services.html

如果一项活动以'bindService()'的服务,则服务将持续到活动电话unbindService()'。

If an activity starts a service with 'bindService()' then the service will run until the activity calls 'unbindService()'.

这篇关于启动远程服务,并获得结果的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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