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
0
votes
2 answers

android: get dimension of extended view using addOnGlobalLayoutListener but fails

I am implementing the following addOnGlobalLayoutListener so as to measure the Extended View (doodleView) in main activity (A)'s OnCreate section. doodleView = (DoodleView) findViewById(R.id.doodleView); doodleView.setOnTouchListener(this); …
pearmak
  • 4,979
  • 15
  • 64
  • 122
0
votes
1 answer

Android calling onCreate() after finish() when in landscape

I have an activity that starts the Vibrator system service in its onCreate method, then when the user pushes a button it cancels the vibrator, then calls finish() to close the activity. This activity is brought up via the AlarmManager, so when it…
Rabbit
  • 115
  • 2
  • 10
0
votes
3 answers

why onCreate reload again on orientation change

currently i am designing an application in which i have a list and alphabetic scrollbar for the list. To load the data in list, i am calling a method in onCreate and also calling one method to build the alphabetic scrollbar for the list. now my…
Sachin Kadian
  • 201
  • 3
  • 12
0
votes
2 answers

Android Beginner Save/Load small information

I am looking to save/load a very easy application in android. The thought would be checking if a file exists in the onCreate() method and if it does load the settings in onCreate. Is this the right function to do this in? Saving is done in the…
Adrian Jandl
  • 2,985
  • 4
  • 23
  • 30
0
votes
2 answers

Android onCreate and AsyncTask delay

My app needs to load some JSON before it can show anything on the UI, the JSON determines how the app should be themed. Although I don't usually like them, a splash screen / loading screen is required so that the user doesn't have to see each…
SteveEdson
  • 2,485
  • 2
  • 28
  • 46
0
votes
1 answer

Android spinner reports null value in oncreate

I have this code in my onCreate and I get a null pointer exception if I uncomment the sortMode(position) line. The log works just fine though, which seems weird to me. What am I doing wrong? I want it to call sortMode() when an option on the spinner…
GrilledCheese
  • 311
  • 3
  • 8
  • 13
0
votes
1 answer

Android - Cannot change layout using v4 Fragments

My users should be able to change (using preferences) how the interface looks like (visually enabling and disabling certain layouts dynamically) in my app. I'm working with the v4 ViewPager (PagerTabStrip to be exact) and am trying to change this in…
Armadillo
  • 457
  • 1
  • 9
  • 17
0
votes
1 answer

Button resets when opening app via notification

I've created an application where you press "start logging" which starts a service that periodically logs data. The button changes to show "stop logging". You then minimize the application and allow it to log in the background whilst you go about…
fypfyp
  • 206
  • 4
  • 10
0
votes
2 answers

How to set the Background Color of a View in onRestoreInstanceState()

I'm currently trying to learn to work with Views and states. I'm normally able to set its color in functions like in the following: View mColorRegion = findViewById(R.id.color_region); mColorRegion.setBackgroundColor(Color.CYAN); However,…
Billy
  • 607
  • 2
  • 8
  • 20
0
votes
3 answers

Why is onCreate crashing Android App when I call onClick?

I'm trying to load a new view when I push a Button. I have a viewPager and the button is on those views. When I call onClick my app never starts, it crashes before anything happens. I've been trying to squash this bug for over a week and I think…
Jason Cheladyn
  • 565
  • 1
  • 12
  • 24
0
votes
1 answer

onResume mess up my layout and make icons larger

I have an application which includes onCreate and OnResume as follows: MenuActivity public class MenuActivity extends Activity { AdView adView ; TextView tv; int weekSince; int numberOfDaysSince; static String DueDateChanged =…
Android Developer
  • 1,039
  • 1
  • 9
  • 33
0
votes
1 answer

Android: How to create new Database tables dynamically by the users themselves?

I am trying to figure out a way to dynamically create new tables in my DB upon user request. My current DB class works with the following code. I am trying to figure out how to change this to be able to dynamically create new tables. One of my ideas…
Georgi Angelov
  • 4,338
  • 12
  • 67
  • 96
0
votes
0 answers

onbackpressed exits the application

I have an application that has a Main menu (MainMenu.java) which starts an activity (ActivityBlah) on a menu button press: public void onClick(View v) { switch (v.getId()) { case R.id.AcitivityBlahButton: startActivity(new Intent(MainMenu.this,…
0
votes
4 answers

How to delay an activity until user accept alert dialog

I have an quiz app. and i want the user to choose the type of questions from alert dialog . so the alert dialog has a check boxes buttons so if the user can select more then on type. when the user click the positive button in alert dialog it will…
Taha
  • 551
  • 1
  • 5
  • 18
0
votes
0 answers

Prepoulating Components With Data In Android Activity onCreate without Getting null pointer exception

I have a FragmentActivity with a ViewPager. Inside that ViewPager are a total of 3 different views. The user selects a row containing information. Once selected, the FragmentActivity shall load and present the data in the views within the…