When pressing a button to switch intents, I get the Chicago Train Tracker has stopped unexpectedly and a logcat of:
09-02 19:54:15.745: D/AndroidRuntime(20681): Shutting down VM
09-02 19:54:15.745: W/dalvikvm(20681): threadid=1: thread exiting with uncaught exception (group=0x41ab6700)
09-02 19:54:15.755: E/AndroidRuntime(20681): FATAL EXCEPTION: main
09-02 19:54:15.755: E/AndroidRuntime(20681): java.lang.IllegalStateException: Could not find a method sendMessage(View) in the activity class com.dev.chicagotraintracker.MainActivity for onClick handler on view class android.widget.ImageButton with id 'Button'
09-02 19:54:15.755: E/AndroidRuntime(20681): at android.view.View$1.onClick(View.java:3620)
09-02 19:54:15.755: E/AndroidRuntime(20681): at android.view.View.performClick(View.java:4240)
09-02 19:54:15.755: E/AndroidRuntime(20681): at android.view.View$PerformClick.run(View.java:17721)
09-02 19:54:15.755: E/AndroidRuntime(20681): at android.os.Handler.handleCallback(Handler.java:730)
09-02 19:54:15.755: E/AndroidRuntime(20681): at android.os.Handler.dispatchMessage(Handler.java:92)
09-02 19:54:15.755: E/AndroidRuntime(20681): at android.os.Looper.loop(Looper.java:137)
09-02 19:54:15.755: E/AndroidRuntime(20681): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-02 19:54:15.755: E/AndroidRuntime(20681): at java.lang.reflect.Method.invokeNative(Native Method)
09-02 19:54:15.755: E/AndroidRuntime(20681): at java.lang.reflect.Method.invoke(Method.java:525)
09-02 19:54:15.755: E/AndroidRuntime(20681): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-02 19:54:15.755: E/AndroidRuntime(20681): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-02 19:54:15.755: E/AndroidRuntime(20681): at dalvik.system.NativeStart.main(Native Method)
09-02 19:54:15.755: E/AndroidRuntime(20681): Caused by: java.lang.NoSuchMethodException: sendMessage [class android.view.View]
09-02 19:54:15.755: E/AndroidRuntime(20681): at java.lang.Class.getConstructorOrMethod(Class.java:423)
09-02 19:54:15.755: E/AndroidRuntime(20681): at java.lang.Class.getMethod(Class.java:787)
09-02 19:54:15.755: E/AndroidRuntime(20681): at android.view.View$1.onClick(View.java:3613)
09-02 19:54:15.755: E/AndroidRuntime(20681): ... 11 more
09-02 19:54:16.875: I/Process(20681): Sending signal. PID: 20681 SIG: 9
My code is:
MainActivity.java
package com.dev.chicagotraintracker;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);}
public void login_Click(View v) {;
Intent myIntent = new Intent(MainActivity.this, Screenmap.class);
startActivityForResult(myIntent, 0);
}
public void onClick(View v) {
// TODO Auto-generated method stub
}
;
}
Screenmap.java
package com.dev.chicagotraintracker;
import android.os.Bundle;
import android.app.Activity;
public class Screenmap extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screenmap);
}}
and AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dev.chicagotraintracker"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.dev.chicagotraintracker.MainActivity"
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="Screenmap" android:label="Screenmap"></activity>
</application>
</manifest>