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
1 answer

Is super's onCreate(0 called in an extended class that has no onCreate() itself?

I have a class that extends Activity like so: public abstract class AndroidGame extends Activity implements Game This class has an onCreate() method like this: public void onCreate(Bundle savedInstanceState) { // I do stuff here } Then I make…
Captainlonate
  • 4,878
  • 4
  • 25
  • 35
0
votes
2 answers

Activity crashes on onCreate()

I built a DB using SQLite and when I try to run my main activity file which populates the DB it crashes on onCreate. I doesn't get to load the activity. My onCreate method opens a db using getWriteableDatabase and from I just add the values…
K D
  • 115
  • 1
  • 3
  • 12
0
votes
1 answer

Android Spinner: Selection impossible if called outside of onCreate()

I've got the following minimal program that shows my problem (android 2.2 (API 8)): If I call the start()-Method from onCreate() everything works fine but if I call it from onWindowFocusChanged() I'm not able to select an item from the spinner. Can…
thomas
  • 1
0
votes
4 answers

start intent without onCreate {}

I have created a class which extends Gallery. There is no onCreate() method in super Class, and I'm unable to run my intent. This is my sample code: this.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void…
melvintcs
  • 551
  • 3
  • 13
  • 34
0
votes
2 answers

Starting an alternate activity on startup if certain conditions satisfy

I am creating an app that requires some settings to be set first before starting the display activity. I would like the app to check if a preference file (that contains these settings) exists and if it does exist move to a particular…
jaisonDavis
  • 1,407
  • 2
  • 22
  • 36
0
votes
1 answer

Android: Calling Second time onActivityResult throw error

In my application it captures some images when I click on a button. When I click this button first time then camera Intent open after that onActivityResult is called by the application and then onResume method called by the application every thing…
Vinit ...
  • 1,409
  • 10
  • 37
  • 66
0
votes
5 answers

Android: auto start an app and exit when finish in onCreate()

I want to make a test app, that when called, execute a few lines of code, and then exit automatically. I want all these done within onCreate(). @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
zhoubo
  • 39
  • 8
0
votes
2 answers

Save state for onPause and onResume

I'm even not sure I've written the title correctly, because this is the first time I feel I have to cope with this methods. In onCreate(), I make a notification with default sound printing a string. Then, I check to see if I get another String. If…
azizbekian
  • 60,783
  • 13
  • 169
  • 249
0
votes
2 answers

When to register for location updates?

I am writing an Android application that requires the user's current location. I register for location updates both from the network, and from GPS using the following code (locationManager is already defined): // Register the listener with the…
DanielGibbs
  • 9,910
  • 11
  • 76
  • 121
0
votes
1 answer

Android app: Help screen on startup unless user sets preference not to. How?

There are posts that touch on this question, but no one that I can find that really directly approaches it or solves it. I have a main Activity that I want to call/create a help screen (it is really a second activity) when the user first gets into…
user1418094
0
votes
1 answer

How to set values in rails without form field

We have an field in the Database which should be set automatic as an UUID String. how do we that. the view doesn't contain this field because it will be autogenerated. Our new-form will called so. def new @list = List.new respond_to do |format| …
amarradi
  • 109
  • 3
  • 16
0
votes
3 answers

Requesting Location updates in oncreate method

I am trying to implement a location alarm kind of application. But whenever my application opens. my current location shows as null. Below is my code. package com.hrupin; import android.app.Activity; import android.app.AlertDialog; import…
Satheesh
  • 646
  • 1
  • 10
  • 33
0
votes
1 answer

jQuery: create any new object after creation of one object

I want to insert one object like $('

Test

').prependTo('#TB_window'); just whenever #TB_window object is created. How it can be made after the creation of a thickbox? I want to use that in the wordpress site http://hogdal.dk/?p=60 Just see…
itsazzad
  • 6,868
  • 7
  • 69
  • 89
0
votes
3 answers

Android: calling getExternalFilesDir( null ) from Application.onCreate() returns null

On some customer devices calling getExternalFilesDir( null ) (and rarely getFilesDir()) from Application.onCreate() returns null. The documentation says nothing about not being able to call these methods from an Application object and on most…
user656226
  • 101
  • 2
  • 4
0
votes
2 answers

Android. How to move the imageview(set position/margin) when it is created

I want to put some images in an area at the application start. As the number of images is not a fixed amount, so I have to create images dynamically. I want to set the position/margin of every images while they're created for good balance. I have…
kinglomei
  • 126
  • 1
  • 1
  • 7