Sagar Pawar
Sagar Pawar

Reputation: 475

Performance of Android Application based on Activity and Fragment

What would be the effect on android application if i use only Activities instead of using Fragments or any other Interface in my Application?

Basically am creating an application wherein i have separate login for Users as well as Administrator and a common login page for both. comparing their login data am redirecting them to their respective activities.

But i wonder what would be the performance of the app if i use only activities for their respective process.

Could someone suggest in short manner the performance difference between Activity and Fragment?

Upvotes: 0

Views: 179

Answers (2)

frogatto
frogatto

Reputation: 29285

You're comparing apples and oranges. They are not interchangeable. You should use them regarding for what requirements you would mind.

Basically the performance would heavily depends on:

  • How big your XML layout is.
  • How much tasks are getting done in UI thread.
  • How frequent you are switching between views.

It should be noted that, in some cases using fragments just worsen the performance, because essentially once you attach a fragment, you are combining view hierarchy of both (that of activity and that of fragment) trees into one tree, which result in having a big tree. Now issuing a requestLayout() would affect the whole tree.

Dilemma: when to use Fragments vs Activities:

Upvotes: 2

Naxos84
Naxos84

Reputation: 2038

Since i cannot comment at the moment I will put this as an answer here.

You should have a look at the following Activity or Fragment which is better way to use for performance and reliable? and also all the related topics. Then you might find your answer there.

Upvotes: 0

Related Questions