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

OpenGL onCreate fragment view in Android

I've created OpenGLRenderer.java class and placed some code in it, shows no errors. Then I placed this code for creating a view in RoomFragment.java fragment: public class RoomFragment extends Fragment { /** Called when the fragment is first…
3mpetri
  • 599
  • 1
  • 9
  • 26
3
votes
1 answer

FB.Event.subscribe -> 'comment.create' firing not every time

I have the code: window.fbAsyncInit = function(){ FB.init({appId: myapid, status: true, cookie: true, xfbml: true}); FB.Event.subscribe('comment.create', function(response) { alert('Thanks for Your…
3
votes
2 answers

progress dialog in main activity's onCreate not shown

After the splash screen, it takes about 6 sec to load onCreate contents in the Main activity. So I want to show a progress dialog while loading and here's what I did: import ... private ProgressDialog mainProgress; public void onCreate(Bundle…
Manto
  • 1,069
  • 2
  • 15
  • 34
3
votes
1 answer

Partial order: AsyncTask.get() and onPostExecute()?

I'm instantiating and executing an AsyncTask from my UI thread (in the onCreate() handler of my Activity). I guarantee that the Activity doesn't restart due to config changes (it ignores orientation change, for example). In my Activity.onCreate(): I…
Thomas Calc
  • 2,994
  • 3
  • 30
  • 56
2
votes
0 answers

Android PayPal OnClickListener is not working

I am trying to connect the PayPal to my app. Basically my app will have one Scan button and one PayPal Button on the screen. Scan button calls the ZXing library and scan the barcodes. However, I still cannot connect with PayPal button yet because…
Thet Mon Aye
  • 205
  • 3
  • 17
2
votes
1 answer

Android & Bundles

what is the difference between: myBundle & the one returned by getArguments() @Override public void onCreate(Bundle myBundle) { //on create() belonging to a Fragment super.onCreate(myBundle); // So myBundle vs getArguments() } From my…
pulancheck1988
  • 2,024
  • 3
  • 28
  • 46
2
votes
3 answers

Android - onCreate being called on every launch

I have a very hard to pin down problem. When I install my app from the marketplace, I sometimes see the following behavior: Navigating away from the app calls onStop, as expected Returning to the app calls onCreate for the main activity, instead of…
TomBomb
  • 3,236
  • 5
  • 31
  • 40
2
votes
3 answers

How to tell if the user has finally quit all your activities in android application

I want to set ringvolume to 0 when a user opens my teaching application then return it to the original volume when the user quits. What's the best way of doing this? I can set volume to 0 with no problems The difficulty is knowing when to restore…
jason
  • 427
  • 5
  • 20
2
votes
2 answers

onCreate method keeps getting called when the orientation of device changes

I have an AsyncTask which gets called onCreate() in my Main Activity. In the same Activity if the orientation changes the AsyncTask gets called again. How do I prevent this from happening or how do I restructure my program to avoid this…
2
votes
1 answer

Android going to sleep causes onCreate to run twice

I've got a strange problem with the Activity I'm working on, It starts fine, then when the phone sleeps it runs onPause which is fine. Then however, when the screen is still black it runs the onCreate method again. Then when the phone comes out of…
gunboatmedia
  • 435
  • 1
  • 6
  • 15
2
votes
3 answers

Android: Possible to place a HTTP request outside onCreate in Activity?

I'm new to Android and trying to figure out where to place a HTTP request in order to make it execute only once (when the Activity first become visible). onCreate is always called when returning from onActivityResult (grabbing a pic from the camera…
Dan
  • 173
  • 2
  • 18
2
votes
1 answer

Should onStart still run if you stop a service during onCreate?

From my understanding of application lifecycle (including services) it should go onCreate > onStart > onResume. Based on this understanding, if you shut down the cycle with a this.stopSelf() in the onCreate it should never fire the onStart. …
Ashterothi
  • 3,282
  • 1
  • 21
  • 35
2
votes
0 answers

Is it normal for onCreate() to be called twice during first installation of Android app?

Does onCreate() get called twice during first run (during installation)? I've seen a couple of similar questions regarding this, but they are sufficiently different, and do not answer my question. In Android apps made using Java in Android Studio,…
2
votes
1 answer

SQLiteOpenHelper not calling onCreate

This is the fist time I've used SQLiteOpenHelper (or databases on android). When I get a writeable database I was wondering why onCreate isnt being called on each new instance of the class. Am I doing something wrong? public class DatabaseHelper…
Jon Wells
  • 4,191
  • 9
  • 40
  • 69
2
votes
0 answers

Copy a file in other path immediately it's created

I'm a newbie of PS so I trust in your patience.. I have found in 33958395/copy-file-on-creation-once-complete question this code that works for me but it's freeze when the files are approximatively over 8-10MB and more. A list o small file are…
MAX
  • 21
  • 1