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 8581003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:56:49+00:00 2026-06-11T20:56:49+00:00

I am working on making my first android app. I am trying to start

  • 0

I am working on making my first android app. I am trying to start an activity called SendMessage from another activity called AskReport. I have seen similar questions like this on SO, but none I could find matches my problem.

The code for AskReport activity is as follows:

public class AskReport extends Activity
{
    Button done;
    RadioButton checkedRadioButton;
    RadioGroup group;
    EditText email, info;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ask_report);
        done = (Button) findViewById(R.id.Report);
        group = (RadioGroup) findViewById(R.id.radioGroup1);
        checkedRadioButton = (RadioButton) findViewById(group.getCheckedRadioButtonId());
        info = (EditText) findViewById(R.id.Info);
        email = (EditText) findViewById(R.id.Email);
        }

    public void reportClick(View view){
        Intent intent = new Intent(this, SendMessage.class);
/* Line1 */ intent.putExtra("sender_email", email.getText());      
/* Line2 */ intent.putExtra("additional_info", info.getText());    
/* Line3 */ intent.putExtra("checked_button",checkedRadioButton.getText()); 
        startActivity(intent);
    }
}

The code for activity SendMessage is as under:

    public class SendMessage extends Activity
    {
    String message = "";
    EditText message_to_send;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.send_message);
        message_to_send = (EditText) findViewById(R.id.message_to_send);
        Intent intent = getIntent();
        message += intent.getStringExtra("sender_email");
        message += intent.getStringExtra("additional_info");
        message += intent.getStringExtra("checked_button");
        message_to_send.setText(message);
        }
}   

Once i comment out the three lines marked in the AskReport activity, the SendMessage activity is called successfully, though the text that appears is nullnullnull(understandable).

I have marked the activity entries correctly in the manifest.

As an addition, i am also giving here the logcat messages that appear:

09-10 15:12:57.555: E/AndroidRuntime(1311): FATAL EXCEPTION: main
09-10 15:12:57.555: E/AndroidRuntime(1311): java.lang.IllegalStateException: Could not execute method of the activity
09-10 15:12:57.555: E/AndroidRuntime(1311):     at android.view.View$1.onClick(View.java:3591)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at android.view.View.performClick(View.java:4084)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at android.view.View$PerformClick.run(View.java:16966)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at android.os.Handler.handleCallback(Handler.java:615)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at android.os.Looper.loop(Looper.java:137)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at android.app.ActivityThread.main(ActivityThread.java:4745)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at java.lang.reflect.Method.invokeNative(Native Method)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at java.lang.reflect.Method.invoke(Method.java:511)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at dalvik.system.NativeStart.main(Native Method)
09-10 15:12:57.555: E/AndroidRuntime(1311): Caused by: java.lang.reflect.InvocationTargetException
09-10 15:12:57.555: E/AndroidRuntime(1311):     at java.lang.reflect.Method.invokeNative(Native Method)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at java.lang.reflect.Method.invoke(Method.java:511)
09-10 15:12:57.555: E/AndroidRuntime(1311):     at android.view.View$1.onClick(View.java:3586)
09-10 15:12:57.555: E/AndroidRuntime(1311):     ... 11 more
09-10 15:12:57.555: E/AndroidRuntime(1311): Caused by: java.lang.NullPointerException
09-10 15:12:57.555: E/AndroidRuntime(1311):     at com.example.safeworld.AskReport.reportClick(AskReport.java:44)
09-10 15:12:57.555: E/AndroidRuntime(1311):     ... 14 more
09-10 15:13:00.725: I/Process(1311): Sending signal. PID: 1311 SIG: 9

I have also placed the function in android:onClick="XXXXXX" in the corresponding layout.xml.

Please help me figure out what’s going wrong in those three lines. Thanks for any help!

Edit:

Here is my ask_report.xml:

<?xml version="1.0" encoding="UTF-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/TableLayout2"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView
        android:id="@+id/ask"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/ask_report"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="24dp" />

    <RadioGroup
        android:id="@+id/radioGroup1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <RadioButton
            android:id="@+id/road_accident"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/road_accident" />

        <RadioButton
            android:id="@+id/fire"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/fire" />

        <RadioButton
            android:id="@+id/theft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:text="@string/theft" />

        <RadioButton
            android:id="@+id/other"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:layout_marginBottom="12dp"
            android:text="@string/other" />

    </RadioGroup>

    <TextView
        android:id="@+id/AddInfo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/add_detail" />

    <EditText
        android:id="@+id/Info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="text" >
    </EditText>

    <TextView
        android:id="@+id/AskEmail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/enter_email"
        android:layout_marginTop="10dp" />

    <EditText
        android:id="@+id/Email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textEmailAddress" />

    <Button
        android:id="@+id/Report"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/done"
        android:onClick="reportClick" />

</TableLayout>
  • 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-11T20:56:50+00:00Added an answer on June 11, 2026 at 8:56 pm

    Well, i thought i would answer this myself and let everyone who reads this know the answer.

    The problem with the three marked lines was in Line3 as that was the one which had null value in checkedRadioButton.

    What worked is:

    • I added android:checkedButton="@+id/road_accident" to my RadioGroup to select the RoadAccident by default.
    • Next, I added the onCheckedChangedListener to the RadioGroup which successfully gave me the checkedRadioButton.

    The code goes as under:

    group = (RadioGroup) findViewById(R.id.radioGroup1);
            group.setOnCheckedChangeListener(new OnCheckedChangeListener(){
    
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {
                    // TODO Auto-generated method stub
                    checkedRadioButton = (RadioButton) group.findViewById(checkedId);
                }
            });
    
            checkedRadioButton = (RadioButton) group.findViewById(group.getCheckedRadioButtonId());
    

    Now the Line3 would work perfectly fine.

    Credits:
    Thanks @marmor and @SpK for your help. Sorry, couldn’t select one of your answers as correct as I took half from both of yours.

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

Sidebar

Related Questions

I'm working for the first time on Android. I'm making an app where, at
So I'm making my first Android app, using ADT in Eclipse and working with
I am working on my first iPhone app and making good progress. But there
I'm working on my first Android project, and I'm starting off by making a
Working on my first FB app and making good progress. I know that non-testers
I'm working on making an iPhone version of an Android app that I've written
I am making an application in android. in first activity its displays list of
I am working on making a book catalog searchable using Solr. I have written
I am working on making a twitter client app. One of the requirement of
I am working on making a web service using soap. I'm stuck at trying

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.