Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:57:00+00:00 2026-06-07T15:57:00+00:00

I was following the Dev guide on Google’s site: http://developer.android.com/training/basics/firstapp/starting-activity.html But whenever I press

  • 0

I was following the Dev guide on Google’s site: http://developer.android.com/training/basics/firstapp/starting-activity.html

But whenever I press the button in my emulator the app crashes.
I tried it on my phone and I get the same result. Here is my code
The indentation is not working correctly on here
Main activity:

package com.example.rishubs.app;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.myapp.MESSAGE";
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

/** Called when Button is pressed */
public void sendMessage(View view) {
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    EditText editText = (EditText) findViewById(R.id.edit_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
}

}

My XML:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.rishubs.app"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
         android:minSdkVersion="14"
         android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".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=".DisplayMessageActivity"
        android:label="@string/app_name">

        </activity>
     </application>

</manifest>

My second activity

package com.example.rishubs.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class DisplayMessageActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Get Message from intent
        Intent intent = getIntent();
        String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
        // Create the text view
        TextView textView = new TextView(this);
        textView.setTextSize(40);
        textView.setText(message);

        setContentView(textView);
    }

}

Updated XML:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.example.rishubs.app"
     android:versionCode="1"
     android:versionName="1.0" >

     <uses-sdk
         android:minSdkVersion="14"
         android:targetSdkVersion="15" />

     <application
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
    <activity
        android:name=".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=".DisplayMessageActivity"
        android:label="@string/app_name">

        </activity>
        <activity android:name="DisplayMessageActivity">

        </activity>
    </application>

</manifest>

Logcat:

07-15 18:48:26.605: E/AndroidRuntime(1454): FATAL EXCEPTION: main
07-15 18:48:26.605: E/AndroidRuntime(1454): java.lang.IllegalStateException: Could not find a method send message(View) in the activity class com.example.rishubs.app.MainActivity for onClick handler on view class android.widget.Button
07-15 18:48:26.605: E/AndroidRuntime(1454): at android.view.View$1.onClick(View.java:3031)
07-15 18:48:26.605: E/AndroidRuntime(1454): at android.view.View.performClick(View.java:3511)
07-15 18:48:26.605: E/AndroidRuntime(1454): at android.view.View$PerformClick.run(View.java:14105)
07-15 18:48:26.605: E/AndroidRuntime(1454): at android.os.Handler.handleCallback(Handler.java:605)
07-15 18:48:26.605: E/AndroidRuntime(1454): at android.os.Handler.dispatchMessage(Handler.java:92)
07-15 18:48:26.605: E/AndroidRuntime(1454): at android.os.Looper.loop(Looper.java:137)
07-15 18:48:26.605: E/AndroidRuntime(1454): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-15 18:48:26.605: E/AndroidRuntime(1454): at java.lang.reflect.Method.invokeNative(Native Method)
07-15 18:48:26.605: E/AndroidRuntime(1454): at java.lang.reflect.Method.invoke(Method.java:511)
07-15 18:48:26.605: E/AndroidRuntime(1454): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-15 18:48:26.605: E/AndroidRuntime(1454): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-15 18:48:26.605: E/AndroidRuntime(1454): at dalvik.system.NativeStart.main(Native Method)
07-15 18:48:26.605: E/AndroidRuntime(1454): Caused by: java.lang.NoSuchMethodException: send message [class android.view.View]
07-15 18:48:26.605: E/AndroidRuntime(1454): at java.lang.Class.getConstructorOrMethod(Class.java:460)
07-15 18:48:26.605: E/AndroidRuntime(1454): at java.lang.Class.getMethod(Class.java:915)
07-15 18:48:26.605: E/AndroidRuntime(1454): at android.view.View$1.onClick(View.java:3024)
07-15 18:48:26.605: E/AndroidRuntime(1454): ... 11 more

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:57:02+00:00Added an answer on June 7, 2026 at 3:57 pm

    you have add

    <activity
            android:name=".DisplayMessageActivity"
        android:label="@string/app_name">
    
        </activity>
        <activity android:name="DisplayMessageActivity">
    
        </activity>
    

    replace it with

    <activity
            android:name=".DisplayMessageActivity"
        android:label="@string/app_name"> </activity>
    

    you have define your Activity twice..May be this is the issue of crash.

    EDIT According to your new LogCat

    seams like, conflict is in your onclick methode name in activity_main.xml, in your edit_message, you have attribute like android:onClick="send message" replace it with android:onClick="sendMessage"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was following the Dev guide on google: http://developer.android.com/training/basics/firstapp/starting-activity.html Eclipse gives me this error
im just experimenting with Android + Java. Im following this guide: http://developer.android.com/training/basics/firstapp/index.html Did everything
I've been following Microsoft's guide for installing a dev environment on Windows 7: http://msdn.microsoft.com/en-us/library/ee554869.aspx
I'm following the steps in the dev guide to implement the Google Marketplace (Play)
I'm going by the following code example to dynamically build a preference activity. http://www.linuxtopia.org/online_books/android/devguide/guide/samples/ApiDemos/src/com/example/android/apis/app/PreferencesFromCode.html
I have found the following document at the Android dev site, which works for
I'm following the information here: http://www.yiiframework.com/doc/guide/1.1/en/topics.logging Please take a look at my log component
Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class?
When installing Windows SDK v6.1, following the chromium instructions ( http://dev.chromium.org/developers/how-tos/build-instructions-windows ) I run
I´m using the compatibility library v4+. Following other threads and the dev guide I´m

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.