Questions tagged [oncreate]

onCreate refers to one of the lifecycle methods for several components on the Android platform.

The onCreate method is a lifecycle method of several Android components like Activities, Fragments, Services etc.

For activities and fragments, this is the first lifecycle method to be called when that component is first created. It can also provide a Bundle containing the component's previously frozen state, if there was one. This method is generally used to setup the component (for example in an Activity this would translate to creating the UI views, binding data to widgets etc).

More information can be found in:

995 questions
-4
votes
1 answer

Why can't i call a method within a protected method of the same class

Within the MainActivity class I have got two methods - one public another protected.I am calling the public method from the protected method.I am running the app and the app crashes.If i cut/paste the code in the protected method everything works…
-4
votes
2 answers

On create method not called after constructor

I am creating an object of class which has Sqlite database methods but when I call that class, my constructor is called but call is not going inside onCreate method.. My call is again returned back to caller class ...please tell me what I do to…
user3407138
  • 15
  • 1
  • 6
-5
votes
1 answer

Error:(106, 20) error: method onCreate(Bundle) is already defined in class MainActivity

I am having trouble adding Google AdMob code from another project, as it seems that a part of my code also uses onCreate(Bundle). Here's the part of my project that uses onCreate(Bundle) from the MainActivity.java: @Override protected void…
ruslan024
  • 1
  • 1
-5
votes
1 answer

error: cannot find symbol method setContentView(int)

I'm quite new in Android Studio. I am having a problem with setContentView. I know that it doesn't work in Fragment. Anyone know how to fix this issue? Error: error: cannot find symbol method setContentView(int) Code: public class Tab1Fragment…
kasia
  • 1
  • 3
-5
votes
3 answers

where is best place to get the resources in the activity

i want to know where is the best place i should get the resources of the views in android.. for example should i get the resource in onCreate() or onStart();
BDeveloper
  • 1,175
  • 6
  • 24
  • 44
1 2 3
66
67