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

How do I put the Loader, onLoadFinish, and onLoadReset into "public void onClick(View view) {"

How do I put the Loader, onLoadFinish, and onLoadReset into "public void onClick(View view) {" This is the Code I have in my main activity I need to put my loader that is in the oncreate section into my onclicklistener. I put the init loader in a…
2
votes
2 answers

Changing screen orientation issue: onCreate

I have an issue when changing my screen orientation. I have an activity with 2 intents that gets called by a service. When I rotate the screen, going into landscape mode, it recalls onCreate. The issue is I have a button, and TextField which gets…
Jary
  • 85
  • 3
  • 7
2
votes
0 answers

Dialog doesn't work on onStart or onCreate but works great after minimizing and opening back

I Implement a dialog which asks user to enter the PIN for security, The dialog displays when app runs but keyboards showing qwerty keyboard but in xml I has set inputType="numberpassword" and pressing any keys in quetry doesnot takes any input in…
apple appala
  • 474
  • 6
  • 14
2
votes
2 answers

Could not find the onCreate() method

I want to add Admob to a project. In the main java class I couldn't find the onCreate() method to add the Adview and AdRequest in order to initialize the Google Mobile Ads SDK package ***************** import…
Mounir Lardjem
  • 127
  • 2
  • 7
2
votes
1 answer

Android CommitNow Does Not call onCreateView from onCreate

Create app with a Fragment containing a Button id=button In @Override protected void onStart() { super.onStart(); getSupportFragmentManager() .beginTransaction() .add(R.id.activity_main, new…
2
votes
3 answers

Which method is called after an intent starts an Activity?

I know that when an activity is first created its onCreate() method comes into play. Assume that there's a main activity which starts another activity (secondActivity.java) through an intent and then that second activity starts the main activity…
Rohan Bhatia
  • 1,870
  • 2
  • 15
  • 31
2
votes
1 answer

Android Application class method onCreate being called lately

I've overloaded the Application class in my android app and i'm usingIAviaryClientCredentials` interface. public class AppypieApplication extends Application implements IAviaryClientCredentials { public ArrayList bis; public…
Maveňツ
  • 1
  • 12
  • 50
  • 89
2
votes
1 answer

OnCreate of Application class is not called in Android 6

I have an Application class, but the OnCreate method is not called on my HTC One m8 (Android 6). On the emulator (Android 5.1) it works fine. public class App extends Application { private static Context context; @Override public void onCreate()…
tomhogenkamp
  • 83
  • 1
  • 11
2
votes
2 answers

How can I prevent init the onCreate again after change permissions in Android

As title, when I change permission and go back to the app, the app init the onCreate again, can I prevent it? User maybe execute some operation before change permission, except store data to sqlite or static parameters, have any good idea to show…
rocoo
  • 61
  • 6
2
votes
1 answer

How to prevent the calls to onCreate/onCreateView methods if the activity is finishing

I have an ActivityA and which host a fragmentA onAttach() method of fragmentA, I need to check some conditions and if it fails, I need to finish the activity. I'm finishing the activity by calling getActivity().finish(). Even after I call the…
2
votes
2 answers

android onCreate(Bundle savedInstanceState)

I am trying to pass an object to an activity through Intent, and as I'm debugging, I noticed that apparently I never even get into the onCreate() method of the activity. Even though the activity starts, I have the layout and everything, I don't get…
mcCat
  • 120
  • 2
  • 13
2
votes
0 answers

What is the performance impact of onCreate() and onStart() on activity startup

Whenever a new Activity is created onCreate is called. Followed by onStart. And onStart is called again when activity is back on to the screen. I know this fundamentals. But, what is the actual difference between when you launch the activity. I…
kirtan403
  • 7,293
  • 6
  • 54
  • 97
2
votes
1 answer

When to set Resource for ImageView in Android NavigationDrawer

I have trouble deciding where to set the image of an ImageView contained in the Android NavigationDrawer. My Android app has a NavigationDrawer that contains an ImageView nested into a couple of other elements inside the NavigationDrawer header…
mattu
  • 944
  • 11
  • 24
2
votes
1 answer

LocationServices.FusedLocationApi.getLastLocation not working in onCreate() method

Here is my code that uses the same method - once during onCreate() in my MainActivity and once after user clicks a button // Below code not working during onCreate StrictMode.ThreadPolicy policy = new…
zooter
  • 2,128
  • 1
  • 13
  • 23
2
votes
1 answer

bindService not working inside a button click but works in onCreate - android

I have a pretty simple local service that I'm trying to bind to my activity. I worked through this yesterday with CommonsWare and he got me straightened out as I was having a difficult time getting the service to bind. It turns out that the reason…
Kyle
  • 10,839
  • 17
  • 53
  • 63