Answer the question
In order to leave comments, you need to log in
How to resolve an intent to an Activity instance? Are there any architectural errors for such a problem?
Good evening. Faced the problem of the following plan.
About 50 Activities are planned in my Android application (this is a quiz), but in order not to write a bunch of classes, I decided to make 1 class from which, according to Layouts, new ones are generated for different Activities.
When creating an Intent to go to the specified instance, the application logically crashes when debugging - I did not describe this Activity in AndroidManifest.xml, and how if I work with instances?
Maybe the point is generally in a design error and it was not necessary to create instances, but go the other way?
Answer the question
In order to leave comments, you need to log in
Of course it's better to go the other way. If there is only one activity, then there is no need to communicate with intents. What prevents you from making the function of loading the required layout with setting the events of the components of the layout and the function of processing these events that is common to all layouts?
Activate one, no need to reboot.
Moreover, if your quiz questions have the same structure, then it may not make sense to produce 50 layouts, but store the data, say, in raw XML or SQLite and inflate the view programmatically using one layout.
In such a situation, it is better to use fragments.
To display the question, create a snippet and make it customizable.
And for each question, create a new fragment instance and customize it according to the question.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question