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

How to call onCreate method from other class?

I want to call onCreate(Bundle cicici); from other class then i am getting "NullPointerException", so please guide me how can i call the onCreate() from another class.
Selva
  • 839
  • 10
  • 25
  • 40
2
votes
1 answer

Writing Firebase functions in languages other than JS

I want to implement Firebase's Firestore Functions like onCreate or onUpdate but I would like to know if it actually supports other programming languages other than JavaScript or TypeScript for such purposes? I've done some research, most people say…
2
votes
0 answers

How to handle uninitialized resources required for Dagger injection in onCreate after activity re-creation?

I’m adding Dagger to my legacy Android application and trying to figure out how to deal with dependencies that rely on non-Dagger objects that are created during normal app initialization but are not recreated during activity restart after…
Aidan64
  • 573
  • 1
  • 5
  • 12
2
votes
0 answers

Delphi OnCreate: strange behaviour while creating a form

I am still using Delphi 10.3.3 I have my own form class TMyForm = class( tForm ) public constructor Create(AOwner: TComponent); override; end; { ... } constructor TMyForm.Create(AOwner: TComponent); begin { code block A } inherited…
Jens
  • 347
  • 1
  • 12
2
votes
0 answers

onCreate runs 2 times with singletop launch mode set

Problem: My Launching Activity creatively named LoadingActivity's onCreate method is called 2 times. Manifest Content: ...
CybeX
  • 2,060
  • 3
  • 48
  • 115
2
votes
0 answers

Will disconnect from debugging mode when reaching break point

I created a simple app and start in Android Studio version 3.6.2. I have N Android 10 real device and when I create a break point in onCreate(), Android Studio jumps to the break point successfully, but after 5 seconds it will disconnect from…
2
votes
3 answers

why does onStart() method run before onCreate in my android project?

According to the activity lifecycle, onCreate() is called once when the app is created, followed by the onStart() method which may be called multiple times throughout the activity lifecycle. Yet that's not whats happening to me. I have this code…
Vladimir Rosca
  • 377
  • 1
  • 2
  • 15
2
votes
0 answers

How can I avoid android.app.RemoteServiceException - Context.startForegroundService() did not then call Service.startForeground()

I am continuing to see a lot of crashes in the wild for this, despite the fact that I am in fact calling startForeground. For reference, my code is below: In my app's main activity onCreate, the very last thing I do is: Intent i = new Intent(c,…
2
votes
0 answers

App runs onCreate() twice on AVD with Android 3.0 due to unexpected configuration change

I have a simple android app, built for API level 7. The only uncommon thing is that it has android:screenOrientation="portrait" in its manifest. Also in its manifest the API levels are specified as android:targetSdkVersion="11"…
2
votes
1 answer

How to avoide call onCreate() when app goes to splitView

In my application there have one activity (MainActivity)and four fragment . when my app goes in splitView (Multi Window mode) the onCreate() method get called in MainActivity and that reason first fragment get loaded when i goes to multiWindow…
2
votes
1 answer

Android resource not found exception oncreate

So I have my app created and it works fine on my phones that I test with, but bugsnag is showing me that it is crashing for other users. Here is the bugsnag report. java.lang.RuntimeException: Unable to start activity…
user2101081
  • 445
  • 5
  • 22
2
votes
1 answer

Fragment is given a null on recyclerView in onCreateView()

Application based on one activity and some fragments. When fragment starts application is crashed with log: java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.alexsuvorov.paistewiki/ru.alexsuvorov.paistewiki.StartDrawer}:…
AlexS
  • 918
  • 1
  • 12
  • 28
2
votes
1 answer

Android how to load a new layout

I'm trying to load a new layout when I click a button, this layout has only a webView in it so my goal is, when the button is clicked that it opens the webView and directs the user to a pre-determined page. Right now I have Button codesBtn =…
Connor
  • 211
  • 2
  • 8
  • 17
2
votes
3 answers

Custom Application class: Constructor vs. onCreate()

One of my Android apps uses a custom Application class to perform some global initialization. This done in the onCreate() method: public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); …
Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
2
votes
1 answer

How to use smartphones back button as webview back button?

I recently started to program with Android studio, I came across a problem. I created a Webview application, and I would like to press the back button on the smartphone once you go back to the previously viewed page, while pressing it twice in a row…