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

  • Home
  • SEARCH
  • 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 8120719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:14:20+00:00 2026-06-06T05:14:20+00:00

I am trying to code an application that monitors sms messages. I want to

  • 0

I am trying to code an application that monitors sms messages. I want to start a service from my main Activity class, but the service doesn’t start for some reason. I think there might be a problem with how I declared my service in the manifest file or how I call it from my activity.
Here is a part of my activity Code:

public class TablighBlockActivity extends Activity {
    /** Called when the activity is first created. */
    private ToggleButton toggEnable;

    public void onCreate(Bundle savedInstanceState) {
        if (loadState("running")==false){startService(new Intent(this, SMSMonitor.class));}
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

and Here is a part of my Service class:

public class SMSMonitor extends BroadcastReceiver {


@Override
public void onReceive(Context context, Intent intent) {

    Intent i = new Intent(context,SMSMonitor.class);
    i.setClass(context, SMSMonitor.class);
    context.startService(i);

And here is my manifest File:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="tabligh.block"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <receiver android:name="SMSMonitor">  
            <intent-filter>  
                <action android:name="android.intent.action.BOOT_COMPLETED" /> 
                <action android:name="android.provider.Telephony.SMS_RECEIVED"></action> 
            </intent-filter>  

        </receiver>

        <activity
            android:name=".TablighBlockActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:enabled="true" android:name=".SMSMonitor"
                                    android:process=":smsmonitor"
                                    ></service>
    </application>

</manifest>

and here is the error log:

06-22 13:46:14.649: W/dalvikvm(1013): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
06-22 13:46:14.668: E/AndroidRuntime(1013): Uncaught handler: thread main exiting due to uncaught exception
06-22 13:46:15.038: E/AndroidRuntime(1013): java.lang.RuntimeException: Unable to instantiate service tabligh.block.SMSMonitor: java.lang.ClassCastException: tabligh.block.SMSMonitor
06-22 13:46:15.038: E/AndroidRuntime(1013):     at android.app.ActivityThread.handleCreateService(ActivityThread.java:2449)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at android.app.ActivityThread.access$2800(ActivityThread.java:112)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1744)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at android.os.Looper.loop(Looper.java:123)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at android.app.ActivityThread.main(ActivityThread.java:3948)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at java.lang.reflect.Method.invokeNative(Native Method)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at java.lang.reflect.Method.invoke(Method.java:521)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
06-22 13:46:15.038: E/AndroidRuntime(1013):     at dalvik.system.NativeStart.main(Native Method)
06-22 13:46:15.038: E/AndroidRuntime(1013): Caused by: java.lang.ClassCastException: tabligh.block.SMSMonitor
06-22 13:46:15.038: E/AndroidRuntime(1013):     at android.app.ActivityThread.handleCreateService(ActivityThread.java:2446)
06-22 13:46:15.038: E/AndroidRuntime(1013):     ... 10 more

Thanks.

  • 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-06T05:14:23+00:00Added an answer on June 6, 2026 at 5:14 am
       public class SMSMonitor extends BroadcastReceiver {
    

    you are SMSMonitor which is a BroadcastReceiver not Service

    Intent i = new Intent(context,SMSMonitor.class);
        i.setClass(context, SMSMonitor.class);
        context.startService(i);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an application that uses the iPhone MapView (under Google Code).
Hi I am trying to write an application that will play morse code. I
I have this code in my ASP.NET application written in C# that is trying
I'm trying to connecting SQL Azure from my android application. The code is working
i'm trying to code an application for Android that fills up a form in
I'm trying to code a native android application that takes certain parts of a
I'm attempting to code an application that reads in the values from an IMU.
I'm trying to work with an application that i don't have the source code
I'm trying to use personal URLs through the code of my application that function
I'm trying to implement undo/redo feature in my custom application that displays code using

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.