Android setContentView or intent?

I have a very simple Android app on the screen.

Is there a drawback to simply disabling layouts using setContentView or should I use intentions? Don't want to poke fun at my app if something is wrong with that.

+3
source share
4 answers

Good, as pointed out by Android Dev http://developer.android.com/reference/android/content/Intent.html

Anent provides the means to perform the last binding at runtime between code in different Applications. Its most significant use is in launching activities, where it can be seen as the glue between activities. It is basically a passive data structure containing an abstract description of the action to be performed.

Therefore, if your two screens are two different applications, I would say that you just want to use setContentView.

it will simplify your code when you want to transfer information from one to another.

+1
source

, . , , . . , , , .

+1

, , , . , "", . - , , , , .

+1
source

If the presentation is easy (a bunch of text fields), then that doesn't matter. On the other hand, if the two screens are largely independent and heavy, you can use two different activities. The main advantages of this approach are:

  • If there is an error in the second screen (in this case, this is an action), your application will return to the first screen, whereas if you use the view, the entire application will fail.
  • Improved readability
  • Easier to add additional features in the future.
0
source

Source: https://habr.com/ru/post/1775127/


All Articles