Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Intents work internally?

I developed an App and i executed some tests. This tests consists in sending data from one background service to another background service. All data was received when the transmission rate was low (4 intents/second). However when i increased the transmission rate (8 and 12 intents/second), some data (typically 2- 3 %) was not received by the destination service.

All intents were broadcasted and the services were running locally.

Can anyone tell me, how the OS treats the Intents and the whole mechanism works, in order to find the reason why data was not received by it's receiver ?

Best regards,

like image 919
João Nunes Avatar asked Jun 18 '12 14:06

João Nunes


People also ask

How do intents work?

An Intent object carries information that the Android system uses to determine which component to start (such as the exact component name or component category that should receive the intent), plus information that the recipient component uses in order to properly perform the action (such as the action to take and the ...

How is intent built?

Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used with startActivity() method to invoke activity, broadcast receivers etc. The dictionary meaning of intent is intention or purpose.

What is intent and explain its types?

Intent is to perform an action. It is mostly used to start activity, send broadcast receiver, start services and send message between two activities. There are two intents available in android as Implicit Intents and Explicit Intents.


2 Answers

First of all, I would rather recommend to bind the service and then using Handlers for IPC. A good example can be found here: http://developer.android.com/guide/components/bound-services.html This is a lot faster and more reliable.

On how Intents work internally you can have a look at the source code: https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/ContextImpl.java#L893

like image 145
Force Avatar answered Sep 23 '22 05:09

Force


Here are the relevant methods (you can see the first one geting called from the ContextImpl.broadcastIntent() method, see the link in Force's answer):

  • ActivityManagerService.broadcastIntent()
  • which in turn calls ActivityManagerService.broadcastIntentLocked()
like image 33
Ivan Bartsov Avatar answered Sep 24 '22 05:09

Ivan Bartsov