拒绝在Android的来电 [英] Rejecting Incoming call in android

查看:281
本文介绍了拒绝在Android的来电的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要拒绝接听在Android中,我看到这么多的code从这些链接。

I want to reject incoming in android, I have seen so many code from these links.

1。     <一href="http://stackoverflow.com/questions/7121508/android-taking-complete-control-of-phone-is-it-possible-how/7121586#7121586">Android:以手机的完全控制,这可能吗?怎么样? 2. <一href="http://stackoverflow.com/questions/7347871/how-to-reject-a-call-programatically-in-android">How在Android的编程拒接来电 3. <一href="http://androidsource$c$c.blogspot.in/2010/10/blocking-incoming-call-android.html">http://androidsource$c$c.blogspot.in/2010/10/blocking-incoming-call-android.html 4. <一href="http://androidbridge.blogspot.com/2011/05/how-to-answer-incoming-call-in-android.html?showComment=1361478035090#c5468022990217431781">http://androidbridge.blogspot.com/2011/05/how-to-answer-incoming-call-in-android.html?showComment=1361478035090#c5468022990217431781 但仍无法做到这一点,有谁能够告诉我,在简单轻松的步骤该怎么办呢?

1. Android: Taking complete control of phone, is it possible? How? 2. How to Reject a call programatically in android 3. http://androidsourcecode.blogspot.in/2010/10/blocking-incoming-call-android.html 4. http://androidbridge.blogspot.com/2011/05/how-to-answer-incoming-call-in-android.html?showComment=1361478035090#c5468022990217431781 But still unable to do it, can anybody tell me in simple and easy steps how to do it?

推荐答案

为了拦截你的电话,你只需要1.命名包。 com.android.internal.telephony。 2.In这个包进行命名ITelephony一个接口文件。 写这个code在接口文件。

In order to Intercept your call you just have to 1. Make a package named. com.android.internal.telephony. 2.In this package make a interface file named ITelephony. and write this code in that interface file.

boolean endCall();
void answerRingingCall();
void silenceRinger();

现在在你的类要截取电话继承了该类到的BroadcastReceiver 的onReceive()函数编写如下code。

Now In your Class where you want to Intercept the call extend that class to BroadcastReceiver and in onReceive()function write the following code.

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
   try {
     Class c = Class.forName(tm.getClass().getName());
     Method m = c.getDeclaredMethod("getITelephony");
     m.setAccessible(true);
     telephonyService = (ITelephony) m.invoke(tm);
     Bundle bundle = intent.getExtras();
     String phoneNumber = bundle.getString("incoming_number");
     Log.d("INCOMING", phoneNumber);
     if ((phoneNumber != null)) { 
        telephonyService.endCall();
        Log.d("HANG UP", phoneNumber);
     }

   } catch (Exception e) {
     e.printStackTrace();
   }

完蛋了。

这篇关于拒绝在Android的来电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆