samjackson7198
I hate code!
Profile
Posts: 8
Reg: Jul 10, 2013
Birmingham
80
07/10/13 04:43 AM (10 years ago)

Very basic code issue!

Hey! I'm a newbie so I appreciate this is probably something obvious. I'm following the tutorials and created a basic Android app in Eclipse (not even touching buzztouch as yet.) Anyways when I include the onStart() method the app crashed in the simulator saying "unfortunately, test1 has stopped". It works if I delete the onStart method. Can anyone see why PLEASE!! package com.example.test1; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MyHomeScreen extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.homescreen); Button myButton = (Button) findViewById(R.id.button1); myButton.setText("hello"); myButton.setOnClickListener (new OnClickListener(){ public void onClick(View v){ Intent nextIntent = new Intent(MyHomeScreen.this , MainActivity.class); MyHomeScreen.this.startActivity(nextIntent); } }); } @Override protected void onStart(){ } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
 
samjackson7198
I hate code!
Profile
Posts: 8
Reg: Jul 10, 2013
Birmingham
80
like
07/10/13 05:31 AM (10 years ago)
ah sorted it - I need to call super.onStart(); in the method.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
07/10/13 10:20 AM (10 years ago)
Happy you figured it out @samjackson7198! Out of curiosity, do you know why you had to call the "super.onStart(); method? LA
 
cybernetuk
Aspiring developer
Profile
Posts: 14
Reg: Jul 07, 2013
West Bromwich
6,390
like
07/10/13 01:00 PM (10 years ago)
Removed - wrong thread!
 
samjackson7198
I hate code!
Profile
Posts: 8
Reg: Jul 10, 2013
Birmingham
80
like
07/10/13 01:02 PM (10 years ago)
Thanks LA - but no I don't! Can you explain? Thanks!!
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
07/10/13 01:24 PM (10 years ago)
Check out this and might help explain the lifecycle: http://developer.android.com/training/basics/activity-lifecycle/stopping.html LA
 
tb
buzztouch Evangelist
Profile
Posts: 2050
Reg: Nov 03, 2011
Oxford
32,300
like
07/10/13 01:56 PM (10 years ago)
@samjackson7198, @cybernetuk: Are you from Birmingham - UK, by any chance. If you didn't know, I run the UK meets in Oxford. I know that it may be inconvenient to come over, but every month, I put together a meet in Oxford for Buzztouch users. It's great fun and even myself (who has come to know a lot about Buzztouch) learns something every time.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.