0

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?

Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73
Sagar Pawar
  • 465
  • 4
  • 26
  • 2
    I dont think using activity instead of fragment will have an impact on performance, performance is usually more related to draw calls, inflater and findViewById calls mostly, a larger xml layout view tree will have slower drawing. – Nanoc Nov 25 '15 at 10:37
  • Most importantly, the usage depends upon requirement.You can't use `Activity` were we should use fragment and vice versa. – Anoop M Maddasseri Nov 25 '15 at 10:40

2 Answers2

2

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:

Community
  • 1
  • 1
frogatto
  • 28,539
  • 11
  • 83
  • 129
0

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.

Community
  • 1
  • 1
Naxos84
  • 1,890
  • 1
  • 22
  • 34