如何在 Android 中阻止来电

发布于 2024-07-26 08:06:59 字数 134 浏览 9 评论 0原文

我想阻止来自几个号码的电话,为此我想编写一个自己的应用程序。 那么我应该使用哪些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

阳光①夏 2024-08-02 08:06:59

我的天啊!!! 是的,我们可以做到!
经过 24 小时的严格调查和发现后,我本来打算自杀……但我找到了“新鲜”的解决方案!

// "cheat" with Java reflection to gain access to TelephonyManager's
// ITelephony getter
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony)m.invoke(tm);

数百位想要开发呼叫控制软件的人请访问 这个起点

有一个项目。 并且有

简要的重要评论(和学分):复制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!

// "cheat" with Java reflection to gain access to TelephonyManager's
// ITelephony getter
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony)m.invoke(tm);

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 !

舞袖。长 2024-08-02 08:06:59

这是可能的,您不需要自己编写代码。

如果传入号码等于空字符串,只需将铃声音量设置为零,并将振动设置为无。 就是这样...

它刚刚通过 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 ...

知你几分 2024-08-02 08:06:59

在android-N中,这个功能就包含在里面了。 检查 Android N 的号码拦截更新

Android N 现在支持平台中的号码阻塞,并提供
框架 API 让服务提供商维护封锁号码列表。
默认短信应用程序、默认电话应用程序和提供商应用程序可以读取
从并写入阻止号码列表。 该列表无法访问
到其他应用程序。

优点是:

  1. 通话时被阻止的号码也会被短信阻止
  2. 被阻止的号码可以通过重置和设备持续存在
    备份与备份 恢复功能
  3. 多个应用可以使用相同的阻止号码列表

有关详细信息,请参阅 android.provider.BlockedNumberContract

更新现有项目。

要针对 Android N 平台编译应用程序,您需要使用 Java 8 Developer Kit (JDK 8),并且为了在 Android 上使用一些工具Studio 2.1,需要安装Java 8运行时环境(JRE 8)

打开模块的 build.gradle 文件并更新值,如下所示:

android {
  compileSdkVersion 'android-N'
  buildToolsVersion 24.0.0 rc1
  ...

  defaultConfig {
     minSdkVersion 'N'
     targetSdkVersion 'N'
     ...
  }
  ...
}

In android-N, this feature is included in it. check Number-blocking update for android N

Android N now supports number-blocking in the platform and provides a
framework API to let service providers maintain a blocked-number list.
The default SMS app, the default phone app, and provider apps can read
from and write to the blocked-number list. The list is not accessible
to other app.

advantage of are:

  1. Numbers blocked on calls are also blocked on texts
  2. Blocked numbers can persist across resets and devices through the
    Backup & Restore feature
  3. Multiple apps can use the same blocked numbers list

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:

android {
  compileSdkVersion 'android-N'
  buildToolsVersion 24.0.0 rc1
  ...

  defaultConfig {
     minSdkVersion 'N'
     targetSdkVersion 'N'
     ...
  }
  ...
}
七分※倦醒 2024-08-02 08:06:59

您只需将联系人中的特定号码重定向到语音邮件即可。 这已经支持了。

否则我想“联系人”的文档将是一个开始查找的好地方。

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.

属性 2024-08-02 08:06:59

您可以通过监听电话事件来做到这一点。 您可以通过将广播接收器连接到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文