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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:20:12+00:00 2026-05-23T11:20:12+00:00

Here is my source code. public class MainActivity extends Activity { private static String

  • 0

Here is my source code.

public class MainActivity extends Activity {
  private static String content;
  private static String phone;
  private String number;
  private String message;

  private  BroadcastReceiver receiver =  new BroadcastReceiver(){

    @Override
    public void onReceive(Context context, Intent intent) {
        //---get the SMS message passed in---
        Bundle bundle = intent.getExtras();        
        SmsMessage[] msgs = null;

        if (bundle != null)
        {
            number = "";
             message = "";
            //---retrieve the SMS message received---
            Object[] pdus = (Object[]) bundle.get("pdus");
            msgs = new SmsMessage[pdus.length];            
            for (int i=0; i<msgs.length; i++){
                msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
                number = msgs[i].getOriginatingAddress();                     

               message = msgs[i].getMessageBody();


            }
            //---display the new SMS message--- 
            Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
            SendMe();
    }
    }


};

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    IntentFilter filter = new IntentFilter(); 
     registerReceiver(receiver, filter);
    setContentView(R.layout.main);



    }


             public void SendMe(){


    PendingIntent pi =  PendingIntent.getActivity(this, 0,
                new Intent(this, MainActivity.class), 0);  
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(number, null, message, pi, null);

}
}

I keep getting this error in the logcat

06-28 17:11:23.241: ERROR/AndroidRuntime(1311):
java.lang.RuntimeException: Unable to instantiate receiver
com.ftt.autospond.MainActivity: java.lang.ClassCastException:
com.ftt.autospond.MainActivity

Here is my manifest

 <?xml version="1.0" encoding="utf-8"?>

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <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>
           <receiver android:name="com.ftt.autospond.MainActivity"> 
        <intent-filter> 
            <action android:name=
                "android.provider.Telephony.SMS_RECEIVED" /> 

  • 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-23T11:20:13+00:00Added an answer on May 23, 2026 at 11:20 am

    Make sure that your activities are registered in your androidmanefest.xml file

    edit: you can’t have your receiver be registered in a preexisting class like that in your manifest. If you do it dynamically in your class there is no need to have it in your manifest… pull that receiver out and see if that takes care of it

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

Sidebar

Related Questions

Here's the relevant bit of the source code: class Dice { String name ;
My class is inherited from UnityContainer (from Unity 2.0), here is source code: public
Here's the relevant code: Public class User.cs: public void FindByID(int id) { Parser parser
Here is a piece of code: public class Schema { public Schema(List<CountryParticipantsStages> places) {
Here is source code: @OneToOne(fetch = FetchType.LAZY) @Cascade({SAVE_UPDATE, EVICT, DELETE}) @JoinColumn(name = A_ID, nullable
you can view full source code here dpaste.com/hold/167199 Error: delete() takes exactly 2 arguments
I have an application I need to analyze. I have the source code here.
I am trying to install MySQLdb package. I found the source code here .
I'm building a python application from some source code I've found Here I've managed
Here is a sample code showing the oddity: (code fixed based on comment) public

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.