public class PhoneCallReceiver extends BroadcastReceiver {
Context context = null;
private static final String TAG = "Phone call";
private ITelephony telephonyService;
@Override
public void onReceive(Context context, Intent intent) {
Log.v(TAG, "Receving....");
TelephonyManager telephony = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
try {
Class c = Class.forName(telephony.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(telephony);
telephonyService.silenceRinger();
telephonyService.endCall();
} catch (Exception e) {
e.printStackTrace();
}
}
//////////////////////////////////////
interface ITelephony {
boolean endCall();
void answerRingingCall();
void silenceRinger();
}
/////////////////////////////////////////////
android:name="android.permission.MODIFY_PHONE_STATE" />
android:name="android.permission.CALL_PHONE" />
android:name="android.permission.READ_PHONE_STATE" />
No comments:
Post a Comment