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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:34:23+00:00 2026-06-08T21:34:23+00:00

I am trying to create an app that can block an incoming call. I

  • 0

I am trying to create an app that can block an incoming call. I am getting ClassNotFoundException for TelephonyManager.Following is the code I am using. What is that I am doing wrong here?

BroadcastReceiver

import java.lang.reflect.Method;
import com.android.internal.telephony.ITelephony;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;

public class TelephoneBroadcastReceiver extends BroadcastReceiver {
    String TAG = "My Tag";
    String incomingNumber = "";
    String incno1 = "5556";
    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub

        Log.d(TAG, "INF: Broadcast received.");

        try{

            TelephonyManager tManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            Log.v(TAG, "Get getTeleService...");    
            Class c = Class.forName(tManager.getClass().getSimpleName());
            Method m = c.getDeclaredMethod("getITelephony");
            m.setAccessible(true);
            com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tManager);
            Bundle bundle = intent.getExtras();

            incomingNumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
            Log.v(TAG,incomingNumber );
            Log.v(TAG,incno1 );
            if ( incomingNumber.equals(incno1) ) {
                 telephonyService = (ITelephony) m.invoke(tManager);
                 telephonyService.silenceRinger();
                 telephonyService.endCall();
                 Log.v(TAG,"BYE BYE BYE" );
            }
            else{
                telephonyService.answerRingingCall();
                Log.v(TAG,"HELLO HELLO HELLO" );
            }           
        }catch(Exception e){
            e.printStackTrace();
            Log.e(TAG,
                    "FATAL ERROR: could not connect to telephony subsystem");
            Log.e(TAG, "Exception object: " + e);
        }
    }
}

Manifest File

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <receiver android:name="com.atiffarrukh.callandsmsfilter.broadcastreceiver.TelephoneBroadcastReceiver" >
            <intent-filter  >
                <action android:name="android.intent.action.PHONE_STATE" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Now the Error

08-02 13:21:20.641: D/My Tag(557): INF: Broadcast received.
08-02 13:21:20.641: V/My Tag(557): Get getTeleService...
08-02 13:21:20.641: W/System.err(557): java.lang.ClassNotFoundException: TelephonyManager
08-02 13:21:20.641: W/System.err(557):  at java.lang.Class.classForName(Native Method)
08-02 13:21:20.641: W/System.err(557):  at java.lang.Class.forName(Class.java:235)
08-02 13:21:20.641: W/System.err(557):  at java.lang.Class.forName(Class.java:182)
08-02 13:21:20.641: W/System.err(557):  at com.atiffarrukh.callandsmsfilter.broadcastreceiver.TelephoneBroadcastReceiver.onReceive(TelephoneBroadcastReceiver.java:30)
08-02 13:21:20.641: W/System.err(557):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
08-02 13:21:20.641: W/System.err(557):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
08-02 13:21:20.641: W/System.err(557):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
08-02 13:21:20.641: W/System.err(557):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 13:21:20.641: W/System.err(557):  at android.os.Looper.loop(Looper.java:123)
08-02 13:21:20.764: W/System.err(557):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-02 13:21:20.764: W/System.err(557):  at java.lang.reflect.Method.invokeNative(Native Method)
08-02 13:21:20.764: W/System.err(557):  at java.lang.reflect.Method.invoke(Method.java:521)
08-02 13:21:20.764: W/System.err(557):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-02 13:21:20.764: W/System.err(557):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-02 13:21:20.764: W/System.err(557):  at dalvik.system.NativeStart.main(Native Method)
08-02 13:21:20.764: W/System.err(557): Caused by: java.lang.NoClassDefFoundError: TelephonyManager
08-02 13:21:20.764: W/System.err(557):  ... 15 more
08-02 13:21:20.764: W/System.err(557): Caused by: java.lang.ClassNotFoundException: TelephonyManager in loader dalvik.system.PathClassLoader[/data/app/com.atiffarrukh.callandsmsfilter-1.apk]
08-02 13:21:20.764: W/System.err(557):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-02 13:21:20.764: W/System.err(557):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-02 13:21:20.764: W/System.err(557):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-02 13:21:20.764: W/System.err(557):  ... 15 more
08-02 13:21:20.764: E/My Tag(557): FATAL ERROR: could not connect to telephony subsystem
08-02 13:21:20.764: E/My Tag(557): Exception object: java.lang.ClassNotFoundException: TelephonyManager

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-08T21:34:24+00:00Added an answer on June 8, 2026 at 9:34 pm

    Use this

    Class c = Class.forName(tManager.getClass().getName());
    

    Instead of getSimpleName() see below link

    http://androidsourcecode.blogspot.in/

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

Sidebar

Related Questions

I am trying to create an android app that has the following: Theme set
I'm trying to create a Rails app template I have this block of code
I am trying to create a Google Drive app that can run in the
I am trying to create an app that saves the user's media selections from
I am trying to create an app that allows you to go to a
I'm trying to create an app that multiple users would log into a server
I am trying to create an app that calculates the time difference and the
I am trying to create a simple app that displays a list of items
I'm trying to create a WinForms app that takes a screenshot on a set
So I'm trying to create an iphone app that does simple temperature conversion and

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.