rkachach
rkachach

Reputation: 17325

Is it a good practice to use intents for communication inside the same application?

I'm working on application where I have several modules and logic running on several threads. Sometimes I need some communication between the different threads to achieve some functionality. I started using Intents for this purpose but I'm not sure if this is a good practice in Android in general or it's an overkill (in terms of usage, performance, etc) since the intent mechanism is designed to be used for inter-app communication.

Upvotes: 1

Views: 83

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93561

Between threads? Why? That's a bit heavyweight. Why not just pass the threads a message with a map of the parameters? Intents are optimized for cross process communication, they really shouldn't be used unless you're starting a new Context. Look into MessageQueues, Handlers, and HandlerThreads for better solutions to the problem.

Upvotes: 2

Related Questions