My question is if it is possible to write code before setContentView() in the onCreate() method of the main Activity. In the code below I
setContentView()
onCreate()
Activity
You can execute any code you want before the setContentView() method as long as it doesn't refer to (parts of) the View, which isn't set yet.
View
Since your setVariables() method refers to the contents of the View, it can't be executed.
setVariables()