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

Android Edittext: Get LineCount in an Activity's onCreate()

How can I do getLineCount() of an Edittext in the onCreate() method of an activity, having changed the Edittext's text, like the following: @override public void onCreate(Bundle savedInstanceState){ myEditText.setText("EXAMPLE"); …
Henry Thompson
  • 2,441
  • 3
  • 23
  • 31
3
votes
3 answers

Using Bundle to move a value from activity to activity but can't get them from on create method?

My java skills are not strong. Only been programming in it for a month or 2 so forgive my stupidness. I'm trying to pass values between methods in a bundle to allow me to save and load some game settings but although I think my values are…
MarbleMad
  • 67
  • 1
  • 1
  • 7
3
votes
2 answers

Cant create Camera preview in onCreate?

I'm having some issues with the preview of the camera on my Android. Right now i have a button you need to press before you get any preview of the camera. but id like to have a preview as soon as you start the app. If i try to take the part that…
Tistatos
  • 641
  • 1
  • 6
  • 16
3
votes
3 answers

Intent error when I click the button - why?

I am having troubles and I can't figure out what the problem is. There is no alert in my code, neither a red line or something. HotelMapActivity.java public class HotelMapActivity extends AppCompatActivity { @Override protected void…
Hirose
  • 105
  • 3
  • 15
3
votes
2 answers

React Native Splash Screen: Unfortunately has stopped after SplashScreen.show()

I'm building a React Native App and I'm using React Native Splash Screen for my splash screen. Let me give you my code first, then I'll explain the issue. res/drawable/background_splash.xml:
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
3
votes
0 answers

Unable to run insert stmt on object SQLErrorCode: 0

I have model with many datafields which are identical with name in database. I recive a Json, then mapping it to the Model (Succeful - ive checked in debug and model is not null and have the atributes) and then I want to create a record with it…
Expiredmind
  • 788
  • 1
  • 8
  • 29
3
votes
1 answer

Android AsyncTask and

Hi i have an AsyncTask in my application called in OnCreate() that retrieve some data over the web and display an indeterminate progress bar while downloading. The problem is when i start the app the screen remain blank until the AsyncTask is…
Martino
  • 103
  • 1
  • 7
3
votes
1 answer

Reduce android app startup time

I am developing an app that uses a shared preferences file and it also contains ads. When I open my app for the first time (running from android studio) my main activity's taking 14-16 seconds to load. After caching it takes 2 seconds to load. I…
VaM999
  • 453
  • 1
  • 9
  • 23
3
votes
3 answers

How do I use findViewById() in onCreate without it returning null?

I don't know how to use findViewById(R.id.nav_timetable); without it returning null and creating an NPE. What I'm trying to do is make the TimetableFragment get loaded by default and then people can use the drawer to go to other…
3
votes
2 answers

Would this be the correct way to access an arraylist from a Fragment?

Just need to know the proper syntax to accessing an array that was created in a different class. public class item_fragment extends Fragment { ArrayList mylist; @Override public View onCreateView( LayoutInflater inflater, …
Carlitos
  • 419
  • 4
  • 20
3
votes
1 answer

calling a method from android service immediately after it's bound on onCreate

I'm pretty sure that android services are going to be the end of me. I have almost no hair left after the last few days.... ...anyway, I digress. At first I was having a heck of a time getting the service to bind on an onclick of a button, got that…
Kyle
  • 10,839
  • 17
  • 53
  • 63
3
votes
3 answers

How to launch the app with a specific Activity only when the app is launched for the first time?

I wanted to start an Activity only the first time my App is launched, and from that point on, the app should launch with another (the launcher) activity every time. So I implemented a solution based on this SO answer. The solution revolves around a…
Solace
  • 8,612
  • 22
  • 95
  • 183
3
votes
5 answers

android what to use instead of onRestart() in a fragment

I'm dealing with .setVisibility() of a view, inside my main fragment at app start. So what I want is that the view is invisible on app start (for this i set INVISIBLE inside onCreateView) and to be visible when I come back to my fragment from other…
m4tt
  • 825
  • 1
  • 11
  • 28
3
votes
2 answers

Model OnCreate Event for Delphi Frame

I am developing a Delphi frame and need to load a list of business objects into a grid control at the beginning. Delphi frames have no OnCreate event, so what is the best way to replicate this? Should I override the constructor like is suggested…
Chet
  • 21,375
  • 10
  • 40
  • 58
3
votes
7 answers

App crashes after receving phone call

After I either receive a phone call or make one, (and other undocumented interruptions) my application gets a NullPointerException when resuming my activity. Can any explain to me where it is and/or how to fix it? When my activity resumes, it is…
Aymon Fournier
  • 4,323
  • 12
  • 42
  • 59