如何在 Android 中阻止来电
我想阻止来自几个号码的电话,为此我想编写一个自己的应用程序。 那么我应该使用哪些 API?
基本上,我想在有电话来电时收到通知,我想比较数字,如果这是我想要阻止的电话,我想切断电话或将其静音,或者如果可能的话将其静音并记录下来。
I want to block calls from few numbers, for that I want to write a app of my own.
So what are the APIs which I should be using?
Basically I want to get notified when a call comes, i want to compare numbers if it is what i want to block, i want to cut the call or mute it or if possible mute it and record it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我的天啊!!! 是的,我们可以做到!
经过 24 小时的严格调查和发现后,我本来打算自杀……但我找到了“新鲜”的解决方案!
数百位想要开发呼叫控制软件的人请访问 这个起点
有一个项目。 并且有
简要的重要评论(和学分):复制aidl文件,添加清单权限,复制粘贴电话管理源)))
为您提供更多信息。 只有获得 root 权限后才能发送 AT 命令。 您可以终止系统进程并发送命令,但您需要重新启动才能让您的手机接收和发送呼叫 =)))
我很高兴 =) 现在我的 Shake2MuteCall 将获得更新!
OMG!!! YES, WE CAN DO THAT!!!
I was going to kill myself after severe 24 hours of investigating and discovering... But I've found "fresh" solution!
all all all of hundreds of people who wants to develop their call-control software visit this start point
there is a project. and there are important comments (and credits)
briefly: copy aidl file, add permissions to manifest, copy-paste source for telephony management )))
Some more info for you. AT commands you can send only if you are rooted. Than you can kill system process and send commands but you will need a reboot to allow your phone to receive and send calls =)))
I'm very hapy =) Now my Shake2MuteCall will get an update !
这是可能的,您不需要自己编写代码。
如果传入号码等于空字符串,只需将铃声音量设置为零,并将振动设置为无。 就是这样...
它刚刚通过 Android Market 中的应用程序 Nostalk 为您完成。 尝试一下...
It is possible and you don't need to code it on your own.
Just set the ringer volume to zero and vibration to none if incomingNumber equals an empty string. Thats it ...
Its just done for you with the application Nostalk from Android Market. Just give it a try ...
在android-N中,这个功能就包含在里面了。 检查 Android N 的号码拦截更新
优点是:
备份与备份 恢复功能
有关详细信息,请参阅
android.provider.BlockedNumberContract
更新现有项目。
要针对 Android N 平台编译应用程序,您需要使用 Java 8 Developer Kit (JDK 8),并且为了在 Android 上使用一些工具Studio 2.1,需要安装Java 8运行时环境(JRE 8)。
打开模块的 build.gradle 文件并更新值,如下所示:
In android-N, this feature is included in it. check Number-blocking update for android N
advantage of are:
Backup & Restore feature
For more information, see
android.provider.BlockedNumberContract
Update an existing project.
To compile your app against the Android N platform, you need to use the Java 8 Developer Kit (JDK 8), and in order to use some tools with Android Studio 2.1, you need to install the Java 8 Runtime Environment (JRE 8).
Open the build.gradle file for your module and update the values as follows:
您只需将联系人中的特定号码重定向到语音邮件即可。 这已经支持了。
否则我想“联系人”的文档将是一个开始查找的好地方。
You could just re-direct specific numbers in your contacts to your voice-mail. That's already supported.
Otherwise I guess the documentation for 'Contacts' would be a good place to start looking.
您可以通过监听电话事件来做到这一点。 您可以通过将广播接收器连接到 PHONE_STATE 和 NEW_OUTGOING_CALL 来完成此操作。 您可以在那里找到电话号码。
然后,当您决定结束通话时,这有点棘手,因为只有 Android P 才能保证正常工作。 检查此处。
You can do it by listening to phone call events . You do it by having a BroadcastReceiver to PHONE_STATE and to NEW_OUTGOING_CALL. You find there what is the phone number.
Then when you decide to end the call, this is a bit tricky, because only from Android P it's guaranteed to work. Check here.