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
-1
votes
3 answers

No such table even though db.execSQL(sql) executes without an error

I have a weird issue to work through. The system properly calls the SQLiteOpenHelper onCreate() method and it also seems that db.execSQL(sql) is successful, but the table is never created. I'm accessing the VM using "adb devices" >> cd into the…
fergatron
  • 13
  • 6
-1
votes
2 answers

onCreate and onRestoreInstanceState(Bundle) not called after startActivityForResult

I'm trying to load an image from gallery. This is the onCreate() : @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gallery_picture); mThis = this; …
SagiLow
  • 5,721
  • 9
  • 60
  • 115
-1
votes
6 answers

How to call a method in Android from onCreate

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); chustilla();} public void chustilla (View v){ //Do anything } When I compile it gives me a problem in the…
user3481906
  • 1
  • 1
  • 1
-1
votes
1 answer

Android New Activity Error

I currently have at least 5 Android Activity in my Android Project. I haven't experience any problems creating those activities. But when I add another activity, It shows an error on the "onCreateOptionsMenu" and "onCreate". Do you have any idea as…
user3422210
  • 53
  • 1
  • 5
-1
votes
1 answer

Unknown nullpointer error?

I have this for loop in my onCreateView for one of my fragments. for(int i = 0; i
Timothy Frisch
  • 2,995
  • 2
  • 30
  • 64
-1
votes
5 answers

Android setText crashes app when called out of onCreate method

In my app in try to change a TextView text using setText. If the call is made in the onCreate method it works just fine but if I call another method to do so it crashes giving me a NullPointerException here is the working code package…
user3214327
  • 33
  • 1
  • 2
-1
votes
2 answers

app crahes onCreate, because of Timer

I have a problem with my app crashing when i try this code? I want i to constantly checking for if the MediaPlayer (MP) is playing, and if it is I want a Text to read "Now Playing" - But if it aint playing i want it to read "Not Playing". I dont get…
ZimZux
  • 29
  • 5
-1
votes
1 answer

Android - App crashes

I need your help... I have an app, it has a splash screen in the onCreate(). Here is the code: public class MainActivity extends Activity { private final int SPLASH_DISPLAY_LENGHT = 3000; @Override public void onCreate(Bundle icicle) { …
user2606414
  • 718
  • 2
  • 7
  • 13
-1
votes
2 answers

NullPointerException when creating android activity

Dear JAVA Programmers, I have come to an NullPointerException in the onCreate method when opening one of my activities. This is what my onCreate method looks like: @Override public void onCreate(Bundle savedInstanceState) { …
-1
votes
1 answer

what is the differences between 2 ways to implement for listView, android

I am learning Android right now and working on the list view to display multiples items for the list. It might be stupid question but I have to ask to find down the reason behind the scenes ( if there are any ) Below are 2 ways to populate the data…
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
-1
votes
1 answer

Unable to resolve superclass of LoginActivity extends FacebookActivity

11-29 11:23:06.101: E/AndroidRuntime(301): at com.mypackage.myapp.MainActivity.onCreate(MainActivity.java:41) I usually don't see this unless it's a problem with the Manifest or the activity wasn't correctly initialized. Only problem is, it is…
-2
votes
2 answers

Why is the Android onCreate() method not called when the AVD is rotated?

My AndroidManifest.xml does not include anything that would cause this (that I know of). I.e. it does not include: android:configChanges="orientation" Android Version: Chipmunk 2021.2.1 Patch 1 class MainActivity : AppCompatActivity() { internal…
mstucki7
  • 1
  • 2
-2
votes
2 answers

android activity only happens once but i need it to repeat

so my app has two tabs tab 1 is a login page then tab 2 is a user details the user needs to loginfrom tab 1 then only details would load from tab 2 so if the user didn't login and goes to tab 2, an alertdialog would show the problem is, after going…
acvon
  • 161
  • 3
  • 6
  • 21
-2
votes
1 answer

execute code after Activity loads in Android

I'm trying my app format some images in the screen after the Activity loads. The problem is while inside onCreate(), onResume() methods my ImageView have width and height=0. How can I run some code after the views are resized? I test onPostResume()…
ChyBy
  • 1,655
  • 2
  • 13
  • 15
-2
votes
2 answers

How to set text of android button in onCreate Method?

I want to set the text of my button in onCreate Method, but it doesn't work. Code in MainActivity-Class: Button button; Code in onCreate: button = findViewById(R.id.button); button.setText("test"); Butto in xml: