When should you use each of the different types of messages for Android?

I have been working Androidfor over a year now, but it’s still hard for me to determine when to use different types of messaging / data exchange between processes / threads. I mainly talk about broadcasting intentions, using AIDL for services, using Handlers to send messages and sockets.

Many of these tools can be used to perform similar tasks, but which are better suited to specific situations?

+5
source share
4 answers

This is a fairly open-ended question, but let me take a picture to describe how I see that interactions between / between applications work best.

One of the key aspects of messaging in Android is the concept of restricting all application components. Since all applications run in a separate process, and one “application” can consist of several applications (responsible for providing different types of activities or services), messaging methods are based on the idea of ​​marshaling messages across process boundaries.

Intents

Your preferred messaging method, always try to use intent when possible. This is the most "native" way to send messages in Android.

Benefits

Intents , . , .

/ Intents, , .

Intents , extras . Intent, .

, , .

Application ( Singleton), , , , .

.

, IPC AIDL

. AIDL - , , , , , .

, . , .

, , AIDL, Android, / , .

AIDL IPC - , , , .

. , , IPC, , - , , Intents.

, , , , - . , - , . , , IPC.

+14

. , AIDL, . , , .

+2

2

  • . , , .
  • , ( - )
  • AIDL// GUI , . , .
+1

This is a good article that I found useful when trying to find a replacement for the Cocoa NSUserDefaults class:

http://developer.android.com/guide/appendix/faq/framework.html

0
source

All Articles