-4

Im creating a social media app where In main activity user can swipe through fragments(with Viewpager). the question is when user clicks on a profile, should app open a new activity for user profile or replace my Viewpager fragment with profile fragment? image

MH. Abdi
  • 298
  • 5
  • 22

3 Answers3

0

It's up to you, both ways are possible. But it's recommended that you keep your architecture with either Activities or Fragments. If you are expected to support and add new features to the app in the future, it's highly recommended that you use Fragments, because they are much more flexible, yet they require a bit more effort from you.

Also, note that with fragments you can have better support for large screens (tablets) and you can take advantage of Fragments' "orientation change proofness" with the setRetainInstance(true); method call.

Sergey Emeliyanov
  • 5,158
  • 6
  • 29
  • 52
0

It really depends on what you want. If there are things in the profile that would be easier to implement using an activity, then do that, but you can basically do everything in a fragment that you would in an activity. Plus, fragments are much faster and offer the ability to be replaced without destroying everything that was initialized in it. It is a good practice to use fragments wherever you can, but sometimes you would rather have an activity.

0

as per your query, I would suggest you kindly use Fragment.. Best conclusions you can read Here

coder_baba
  • 447
  • 3
  • 21