发送广播从一个应用程序到另一个 [英] Send Broadcast from one app to another

查看:81
本文介绍了发送广播从一个应用程序到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在市场上的应用程序2,我们姑且称之为一个APP和APP湾

I currently have 2 apps in the market, let's call them app a and app b.

当某个功能在应用程序执行时,我需要一些东西来触发应用程序中的一个事件,即使一个应用程序当前未运行。我假设应用程序B.将发送广播消息到应用程序中的应用程序和一个需要的广播接收器,但我不知道如何可以做到这一点,如果是可以做到的。

When a certain function is executed in app, I need something to trigger an event in app a, even if app a isn't currently running. I assume app B would send a broadcast message to app a and app a would need a broadcast receiver but I am not sure how this can be done, if it can be done.

任何帮助将是很大的AP preciated,谢谢

Any help would be greatly appreciated, thanks

推荐答案

基本上有两种方式AFAIK:

There are basically two ways afaik:

  • 广播接收器并使用<一个href="http://developer.android.com/reference/android/content/Context.html#sendBroadcast%28android.content.Intent%29">sendBroadcast在发送方法
  • Broadcast Receiver and using the sendBroadcast method on the sender side

或使用意图:

  • 您可以使用startActivity(意向),甚至与其他应用程序,但是这会带来应用到前台,而不是做工作的背景。

使用意图,如果调用应用程序应dissappear和被叫的应用程序应该在前台,并使用广播,如果你只是想通过另一个应用程序执行的后台任务

Use intents if the calling app should dissappear and the called app should be in foreground and use broadcasts if you just want a background task performed by another app

这篇关于发送广播从一个应用程序到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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