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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:20:59+00:00 2026-05-30T13:20:59+00:00

This is the error my logcat is giving me. I understand it has something

  • 0

This is the error my logcat is giving me. I understand it has something to do with my editText but i am not sure what.I am hopeing its a dumb mistake that can be fixed quickly and easily so i can keep working ASAP. Help me if you can Stackoverflow Thanks!

The error only occurs when program is ran

02-25 16:30:19.417: E/AndroidRuntime(15259): FATAL EXCEPTION: main
    02-25 16:30:19.417: E/AndroidRuntime(15259): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Wicker/com.Wicker.InviteSMS}: java.lang.ClassCastException: android.widget.EditText
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.app.ActivityThread.access$1500(ActivityThread.java:132)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.os.Handler.dispatchMessage(Handler.java:99)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.os.Looper.loop(Looper.java:143)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.app.ActivityThread.main(ActivityThread.java:4196)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at java.lang.reflect.Method.invokeNative(Native Method)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at java.lang.reflect.Method.invoke(Method.java:507)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at dalvik.system.NativeStart.main(Native Method)
    02-25 16:30:19.417: E/AndroidRuntime(15259): Caused by: java.lang.ClassCastException: android.widget.EditText
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at com.Wicker.InviteSMS.onCreate(InviteSMS.java:48)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
    02-25 16:30:19.417: E/AndroidRuntime(15259):    ... 11 more

This is my xml file:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/contacts"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:gravity="center"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:paddingTop="10dp"
                android:text="@string/contacts"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#fff" /> <!-- android:background="@drawable/header" for header background -->

            <Button
                android:id="@+id/contactsButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:text="@string/contacts" />
        </RelativeLayout>

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/enter_contact"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <AutoCompleteTextView
            android:id="@+id/contactnumber"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/to" >

            <requestFocus />
        </AutoCompleteTextView>

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/message_to_send"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/invite_text"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/message_join" />

        <Button
            android:id="@+id/sendtxt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:onClick="doLaunchContactPicker"
            android:text="@string/send_txt" />
    </LinearLayout>

</ScrollView>

This is the class that runs it.

public class InviteSMS extends Activity {

    private static final int CONTACT_PICKER_RESULT = 1001;
    private static final String DEBUG_TAG = null;

    private SimpleAdapter mAdapter;

    Button btnSendSMS;
    AutoCompleteTextView txtPhoneNo;
    Button Attachment;
    Button contactsbutton;
    Button gallery;
    EditText txtMessage;

    Context context = this;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.invite_text);

        btnSendSMS = (Button) findViewById(R.id.sendtxt);
        txtPhoneNo = (AutoCompleteTextView) findViewById(R.id.contactnumber);
        txtMessage = (EditText) findViewById(R.id.invite_text);
        contactsbutton = (Button) findViewById(R.id.contactsButton);

        txtPhoneNo.setAdapter(mAdapter);

        btnSendSMS.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                String phoneNo = txtPhoneNo.getText().toString();
                String message = txtMessage.getText().toString();

                if (phoneNo.length() > 0 && message.length() > 0)
                    sendSMS(phoneNo, message);
                else
                    Toast.makeText(getBaseContext(),
                            "Please enter both phone number and message.",
                            Toast.LENGTH_SHORT).show();
            }

        });
        contactsbutton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
                        Contacts.CONTENT_URI);
                startActivityForResult(contactPickerIntent,
                        CONTACT_PICKER_RESULT);

            }
        });
    }

    private void sendSMS(String phoneNumber, String message) {
        PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this,
                InviteSMS.class), 0);

        String SENT = "SMS_SENT";
        String DELIVERED = "SMS_DELIVERED";

        PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(
                SENT), 0);

        PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
                new Intent(DELIVERED), 0);
        registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode()) {
                case Activity.RESULT_OK:
                    Toast.makeText(getBaseContext(), "SMS sent",
                            Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                    Toast.makeText(getBaseContext(), "Generic failure",
                            Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_NO_SERVICE:
                    Toast.makeText(getBaseContext(), "No service",
                            Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_NULL_PDU:
                    Toast.makeText(getBaseContext(), "Null PDU",
                            Toast.LENGTH_SHORT).show();
                    break;
                case SmsManager.RESULT_ERROR_RADIO_OFF:
                    Toast.makeText(getBaseContext(), "Radio off",
                            Toast.LENGTH_SHORT).show();
                    break;
                }
            }
        }, new IntentFilter(SENT));

        // ---when the SMS has been delivered---
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode()) {
                case Activity.RESULT_OK:
                    Toast.makeText(getBaseContext(), "SMS delivered",
                            Toast.LENGTH_SHORT).show();
                    break;
                case Activity.RESULT_CANCELED:
                    Toast.makeText(getBaseContext(), "SMS not delivered",
                            Toast.LENGTH_SHORT).show();
                    break;
                }
            }
        }, new IntentFilter(DELIVERED));

        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
            case CONTACT_PICKER_RESULT:
                Cursor cursor = null;
                String phone = "";
                try {
                    Bundle extras = data.getExtras();
                    Set<String> keys = extras.keySet();
                    Iterator<String> iterate = keys.iterator();
                    while (iterate.hasNext()) {
                        String key = iterate.next();
                        Log.v(DEBUG_TAG, key + "[" + extras.get(key) + "]");
                    }

                    Uri result = data.getData();
                    Log.v(DEBUG_TAG,
                            "Got a contact result: " + result.toString());

                    // get the contact id from the Uri
                    String id = result.getLastPathSegment();

                    cursor = getContentResolver().query(Phone.CONTENT_URI,
                            null, Phone.CONTACT_ID + "=?", new String[] { id },
                            null);

                    int phoneIdx = cursor.getColumnIndex(Phone.DATA);

                    if (cursor.moveToFirst()) {

                        phone = cursor.getString(phoneIdx);

                        Log.v(DEBUG_TAG, "Got Contact: " + phone);

                    } else {
                        Log.w(DEBUG_TAG, "No results");
                    }
                } catch (Exception e) {
                    Log.e(DEBUG_TAG, "Failed to get phone data", e);
                } finally {
                    if (cursor != null) {
                        cursor.close();
                    }
                    EditText phoneEntry = (EditText) findViewById(R.id.invite_text);
                    phoneEntry.setText(phone);
                    if (phone.length() == 0) {
                        Toast.makeText(this,
                                "No Phone Number found for contact.",
                                Toast.LENGTH_LONG).show();
                    }

                }

                break;
            }

        } else {
            Log.w(DEBUG_TAG, "Warning: activity result not ok");
        }
    }

}
  • 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-05-30T13:21:00+00:00Added an answer on May 30, 2026 at 1:21 pm

    You get a ClassCastException at this line:

    txtMessage = (EditText) findViewById(R.id.invite_text);
    

    That means the View object with the id R.id.invite_text is not EditText. However this is not true since invite_text is indeed of type EditText.

        <EditText
            android:id="@+id/invite_text"
            android:layout_width="fill_parent"
            ...
            " />
    

    So I think your resource file is not up to date. The code looks all right. Delete your gen folder and run it again. Your resource file should be recreated when you delete gen folder.

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

Sidebar

Related Questions

Hi if i run my project its indicate this logcat error...how to solve this
This error seems to just pop up now and again. It is not restricted
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Has anyone run into this error message before when using a timer on an
I have got this logcat error more then one time. This time I started
I can't figure out why I'm getting this error in logcat: 02-14 15:44:42.470: E/ActivityThread(32164):
Where should I call close() on the code? The LogCat returns this error: close()
I am getting this error from the logcat org.apache.http.NoHttpResponseException: The target server failed to
I'm building a simple paint app and encountering this error given by the logcat:
I try all this day to resolve this error. I don't understand why my

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.