0
I’m having trouble calling another activity
. Follows code from Activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_principal);
}
public void entrarOnClick(View v) {
Intent intent = new Intent(this, Menu.class);
startActivity(intent);
}
}
and the androidmanifest
<activity
android:name=".Principal"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Menu"
android:label="Menu" >
</activity>
follows the logcat:
09-23 14:03:21.527: E/AndroidRuntime(2464): FATAL EXCEPTION: main
09-23 14:03:21.527: E/AndroidRuntime(2464): java.lang.IllegalStateException: Could not execute method of the activity
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.view.View$1.onClick(View.java:3599)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.view.View.performClick(View.java:4204)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.view.View$PerformClick.run(View.java:17355)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.os.Handler.handleCallback(Handler.java:725)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.os.Looper.loop(Looper.java:137)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.app.ActivityThread.main(ActivityThread.java:5041)
09-23 14:03:21.527: E/AndroidRuntime(2464): at java.lang.reflect.Method.invokeNative(Native Method)
09-23 14:03:21.527: E/AndroidRuntime(2464): at java.lang.reflect.Method.invoke(Method.java:511)
09-23 14:03:21.527: E/AndroidRuntime(2464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-23 14:03:21.527: E/AndroidRuntime(2464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-23 14:03:21.527: E/AndroidRuntime(2464): at dalvik.system.NativeStart.main(Native Method)
09-23 14:03:21.527: E/AndroidRuntime(2464): Caused by: java.lang.reflect.InvocationTargetException
09-23 14:03:21.527: E/AndroidRuntime(2464): at java.lang.reflect.Method.invokeNative(Native Method)
09-23 14:03:21.527: E/AndroidRuntime(2464): at java.lang.reflect.Method.invoke(Method.java:511)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.view.View$1.onClick(View.java:3594)
09-23 14:03:21.527: E/AndroidRuntime(2464): ... 11 more
09-23 14:03:21.527: E/AndroidRuntime(2464): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.radiosu/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.app.Activity.startActivityForResult(Activity.java:3370)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.app.Activity.startActivityForResult(Activity.java:3331)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.app.Activity.startActivity(Activity.java:3566)
09-23 14:03:21.527: E/AndroidRuntime(2464): at android.app.Activity.startActivity(Activity.java:3534)
09-23 14:03:21.527: E/AndroidRuntime(2464): at com.example.radiosu.Principal.entrarOnClick(Principal.java:32)
09-23 14:03:21.527: E/AndroidRuntime(2464): ... 14 more
Welcome to Stackoverflow. What error are you having?
– emanuelsn
Why is there a function inside a function there? inOnClick shouldn’t be inside onCreate
– Pedro Oliveira
It was a question. Missed ?. This problem has already been solved below.
– Pedro Oliveira
You are trying to use another Menu class instead of your own. You see
Menu.class
? You are pointing to android.view.Menu instead of your Menu class. Instead of usingMenu.class
try to usecom.seupackage.Menu.class
– Pedro Oliveira
worked out now, thank you very much.
– juliano