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

How to finish intent after getting values by getExtras?

I am new at developing Android.I want to finish intent after getting values by getExtras onCreate() method of MainActivity. EditDetailActivity(startActivity) ----> MainActivity(onCreate) After I updated detail of the item on EditActivity, I am…
MUMBUÇOĞLU
  • 251
  • 1
  • 8
  • 24
-2
votes
1 answer

findViewbyId returns null - but not when put into a button onClick listener

I want to access a TextView to exhange its label. However, findViewById seems to return null when the code is in onCreate(), onResume() or onStart(). The application crashes only if the //if(Day != null) is not commented by //. The code snippet…
Vince
  • 3
  • 3
-2
votes
2 answers

Android onCreate()-Method not working

I started with my first Apps on Android some days ago. I'm using Eclipse with Android SDK. In every Tutorial, I see Code in onCreate(). But whenever I'm doing something in onCreate(), my App crashes at the start. Do you know what the problem could…
Pidu2
  • 3
  • 1
-2
votes
2 answers

Android Null pointer exception onCreate

So I am just learning to write android apps, nothing specific yet but mainly toying around to see how they work. I tried to do something with tabs in the action bar, based off a tutorial I found, but I get a null pointer exception thrown before the…
user3363625
  • 241
  • 1
  • 2
  • 5
-2
votes
1 answer

Android lifecycle in webview by click on notification

my main activity contains a webview, and i have a notification which says the program is running and when the user clicks on the notification the main activity opens. and my problem is when the user clicks on the notification my main activity starts…
john
  • 9
  • 6
-2
votes
2 answers

Android - Request code in onCreate

can I access the requestCode an activity received in its onCreate() method? I'd need it to understand if it is a "new" or "modify" operation.
Stefano Cazzola
  • 1,597
  • 1
  • 20
  • 36
-2
votes
2 answers

when an activity starts but when do we use onStart()

I know we call onCreate() when an activity starts but when do we use onStart()?
Divyansh
  • 11
  • 5
-3
votes
2 answers

Android, why I cant call my stringarray inside a method outside of onCreate?

Outside my onCreate method my stringarray isnt able to be called , why is that ? I tried to initialize the stringarray again in the method outside onCreate with getResources(); but I cant call that either, im guessing there is some fundemental…
Karlay
  • 17
  • 5
-3
votes
6 answers

setOnClickListener method can't get EditText value

environment: Android Studio 3.1.1 public class AddQuestionActivity extends AppCompatActivity { public Button add_question; public EditText question_EditText; @Override protected void onCreate(Bundle savedInstanceState) { …
Jack Wilson
  • 6,065
  • 12
  • 29
  • 52
-3
votes
1 answer

android onActivityResult and onCreate

I want to know whether onCreate always run at first ? Because in my app, I must set some values in onCreate at first then use them in onActivityResult.
user4254398
  • 373
  • 3
  • 12
-3
votes
1 answer

Speeding up activity loading

I know this has been asked many times but I really never understood any of the answers. I have an activity and it is doing lot of work on the onCreate() hence it takes a while to load the activity. From what I have seen, people are telling to use…
-3
votes
1 answer

How to pass result from onpostexecute method to another activity using intent

How i pass the result obtained from onpostexecute method to another activity or into oncreate method using intent
-3
votes
1 answer

It's ever pass in method oncreate when i call setResult(100,i) and finish()

I've a problem. In device SAMSUNG GT-P3110, when i call to screen searchProducts, selected product and go back using: Intent i = new Intent(); i.putExtra("productID", "1"); setResult(100,i); finish(); It's always pass in method on oncreate in…
-4
votes
4 answers

call an activity on java android

first of all, i'm a noob at java programing for android. Now, I have a button in the main layout that suppose to call an activity, now what do I write in the onClick method of the button? and I can't use onCreate in the activity that is being…
Someonation
  • 175
  • 10
-4
votes
2 answers

onCreate() is not called

This is the code I am using @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); showVoiceText.setText("I am working"); } However it seems not to…
1 2 3
66
67