I followed the developer guides on the Android website. It is working fine for a Hello World application but when I try and transition between Activities, my application keeps giving an “The application () has stopped unexpectedly. Please try again later.” error and the application then quits. This happens when I click the button in the Subscribe Activity.
Subscribe.java
public class Subscribe extends Activity
implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.subscribe);
Button subButton = (Button)findViewById(R.id.subscribe);
subButton.setOnClickListener(this);
}
public void onClick(View v) {
Intent subIntent = new Intent(Subscribe.this,Subscribed.class);
startActivity(subIntent);
}
}
Subscribed.java
public class Subscribed extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.subscribed);
}
}
The Application Name has stopped unexpectedly message is displayed when an uncaught exception occurs. This exception will be in the
logcatoutput, along with a Stack Trace.Looking at the output you posted I found:
So the problem looks to be that you haven’t defined your
SubscribedActivity in yourAndroidManifest.xmlfile.You need to add a line like the following to the file: