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

What code must be run in onCreate() before finish() can be called?

I want to do a test for a condition in an Activity's onCreate() which if true will call finish(). Is there any code which must be called before finish() is called? (And must any code be run after finish() is called?) e.g. protected void…
Jodes
  • 14,118
  • 26
  • 97
  • 156
2
votes
2 answers

Is onStart called when the screen is already visible or becoming visible?

I looked on another thread on stack overflow (src: Difference between onCreate() and onStart()?) That thread described the onStart() method as "Called when the activity is becoming visible to the user". However in that same answer and in many…
committedandroider
  • 8,711
  • 14
  • 71
  • 126
2
votes
2 answers

When I call startActivity() in onCreate(),did the other lifecycle method execute

When I call the startActivity() method to start other activity on the onCreate() method; Did the other lifecircle method execute,like onStart() or onResume() I had a test AppMain.java @Override protected void onCreate(Bundle…
Grumoon
  • 39
  • 1
  • 3
2
votes
2 answers

Android fill up text fields

I have no idea, which factor may cause this problem, as even after debugging, still cannot figure it out. The problem is, that after start of application, I am trying to fill up text fields for login and password with saved data from previous login.…
jpact
  • 1,042
  • 10
  • 23
2
votes
1 answer

Is it possible to display something before the main activity finishes onCreate() in Android?

Given a one-activity app like this: public class MyActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { loadingScreen = new RelativeLayout(this); // add a bitmap to loadingScreen setContentView(loadingScreen); …
DevOfZot
  • 1,362
  • 1
  • 13
  • 26
2
votes
1 answer

onCreate() not being called on orientation change

I have an MainActivty which consists of a Navigation Drawer. The navigation drawer code is pretty close to the official documentation. Now the MainActivty loads FragmentA upon start. The Navigation Drawer is supposed to be only available from…
rgamber
  • 5,749
  • 10
  • 55
  • 99
2
votes
0 answers

Is it possible to create option menu when window is set to full screen?

Is it possible to create option menu when window is set to full screen? And how do I set the window to full screen inside option menu? Inside onCreate i had to commandline the code because i was not able see the option menu when the screen is set…
nandu
  • 123
  • 1
  • 9
2
votes
1 answer

Android activity added but never triggering onCreate()

I've added a new Activity, but the Toast message doesn't ever appear. It's not Toast specific though, it doesn't reach this class in general. public class SecondActivity extends Activity { @Override public void onCreate(Bundle…
2
votes
4 answers

Accessing the global value outside function

I'm Trying to set a value(global) in a function and access it outside function that is in "On create()" in android I've tried making the global variable static, and I even tried to write it in a "edit text" and parsing it in "on create()" . but it…
Ak-
  • 335
  • 4
  • 17
2
votes
0 answers

onCreate keeps being called

I have an simple activity that binds some data to a listView via an ArrayAdapter. I put a toast in my onCreate. If I leave the phone alone for a few seconds-minutes, the toast shows again. I'm totally clueless as of how this is happening. I'm…
EGHDK
  • 17,818
  • 45
  • 129
  • 204
2
votes
2 answers

Getting NFC Unique ID within the oncreate method

I am trying to get the unique ID of a NFC tag within the on create method. I have done this successfully using an override method called "onNewIntent" however i want to get it within the oncreate method. Here is what i have tried, the application on…
2
votes
1 answer

Android: is it possible to load TTS faster?

I am working on a vocabulary app where there would be TTS in most of the activities. I am implementing TTS as illustrated in http://www.androidhive.info/2012/01/android-text-to-speech-tutorial/ However, I discover and is quite certain that setting…
pearmak
  • 4,979
  • 15
  • 64
  • 122
2
votes
3 answers

super.onCreate(savedInstanceState) crashes when activity resumes

My app's main activity starts fine, works fine, everything is dandy - but if you switch away to another app and the app is destroyed by the garbage collector, when you move back to the app it'll crash on "super.onCreate(savedInstanceState)". This is…
Elad Avron
  • 1,411
  • 1
  • 18
  • 28
2
votes
5 answers

AsyncTasks in Main activty How to show the progress dailogue

I have 3 async tasks in my Mainactivty Oncreate() Method when user opens the app i want to show the Progress dialogue while the 3 asynctasks are loaded. please specify where do i start and dismiss the progess dialogue. if any sample please provide a…
2
votes
1 answer

How can I retain my layout in an android fragment on configuration change?

I have got the following problem. I am trying to preserve my layout of one of my fragments on configuration change. Therefore I thought, I would be able to use setRetainInstance(true). However, it turned out not to work. The problem is, that…
user2426316
  • 7,131
  • 20
  • 52
  • 83