tags:

views:

212

answers:

2

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);
 }

}

Logcat Log File

+1  A: 

Please provide a little bit more data - what is the logcat-output for this error?

You get the logcat either in eclipse by going to the DDMS-Perspective, choosing the device the error occurred on and then looking at the LogCat-View.

Or

by invoking adb -d logcat (for hardware devices) or adb -e logcat (for emulators) on the commandline. The adb-executable is in your android-sdk-directory in the subdirectory ./tools.

rflexor
I have added logcat log file. Thanks!
+2  A: 

The Application Name has stopped unexpectedly message is displayed when an uncaught exception occurs. This exception will be in the logcat output, along with a Stack Trace.

Looking at the output you posted I found:

02-11 02:16:00.951: ERROR/AndroidRuntime(188): android.content.ActivityNotFoundException:
Unable to find explicit activity class {org.ghoshna/org.ghoshna.Subscribed}; have you declared this activity in your AndroidManifest.xml?

So the problem looks to be that you haven't defined your Subscribed Activity in your AndroidManifest.xml file.

You need to add a line like the following to the file:

<activity android:name=".Subscribed"/>
Dave Webb
Thanks! I should have read the manifest file dev guide more carefully!