• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Incoming Call Block

Responses

  • Good

    Votes: 1 100.0%
  • Good

    Votes: 0 0.0%

  • Total voters
    1

RameshbabuK

Newbie
Apr 16, 2014
23
2
Hi,

I tried to block incoming calls. And I tried to achieve this task using broadcast

receiver. But my class not triggered and I cant fix this issue. And tried to many

tutorials but even i cant be fix it. So please help me to solve this issue:(.



My Code:

try {

// Java reflection to gain access to TelephonyManager's
// ITelephony getter
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony telephonyService = (ITelephony) m.invoke(tm);
telephonyService = (ITelephony) m.invoke(tm);
//
telephonyService.silenceRinger();
telephonyService.endCall();
} catch (Exception e) {
e.printStackTrace();
}


Manifest File:

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

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />


<uses-feature
android:name="android.hardware.telephony"
android:required="false" />

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

<receiver android:name=".myReceiver" >
<intent-filter android:priority="100" >
<action android:name="android.intent.action.PHONE_STATE" >

</action>
</intent-filter>
</receiver>
</application>

</manifest>
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones