I'm attempting to start an intent with the following code:
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.buttonEvaluate:
evaluateAnswer();
break;
case R.id.buttonHelpMe:
Intent intent = new Intent(this, HelpMenuActivity.class);
startActivity(intent);
break;
}
}
However the app crashes every time. If I change HelpMenuActivity to another activity, it works just fine. I deleted and recreated the HelpMenuActivity and stripped everything out of the code files...
XML Layout:
< ?xml version="1.0" encoding="utf-8"?>
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
< /RelativeLayout>
And HelpMenuActivity.java:
import android.app.Activity; import android.os.Bundle;
public class HelpMenuActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
this.setContentView(R.layout.activity_help_menu);
super.onCreate(savedInstanceState);
}
}
I've tried changing R.layout.activity_help_menu to another layout that works, and it still crashes.
Make sure you add the new Activity to your AndroidManifest.xml file or it will crash on you every time.
Within the applicationa block, you need to add something that looks like this:
<activity
android:name="com.packagename.HelpMenuActivity"
android:label="@string/app_name" >
</activity>
Did you declare the HelpMenuActivity in the android manifest?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With