Devrath
Devrath

Reputation: 42834

When to use Intents(putextra,getextra) & When to use Arguments(set,get) to pass data in ANDROID

I am trying to learn passing data in android

  1. So far i was using Intents to send data between the two different activities
  2. Now, when i started learning fragments, i notice that when i deal with interfragment communication from developers site between 2 fragments in single activity i am passing data as setArguments and getArguments

im-confused


My Questions::


Upvotes: 0

Views: 525

Answers (2)

Jitesh Upadhyay
Jitesh Upadhyay

Reputation: 5260

Intent is always good to send the primitives/Strings/Object etc. between two different activities while when we wants to send data between two different fragment it is good to send/pass them as Bundle args.

Intents are message passing system used for communication between two different activities while on the other hand the same communication is better with setting and getting bundle arguments in case of fragments.

Upvotes: 1

amit singh
amit singh

Reputation: 1422

Intents are used for communication between different activities and set-arguments are used for communication between two fragments. You can check this link- http://developer.android.com/training/basics/fragments/communicating.html#DefineInterface

Upvotes: 1

Related Questions