- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
if (incomingNumber == null || "".equals(incomingNumber)) {
return;
}
break;
}
}
我在 Android sdk27 以下遇到过同样的问题,我在 PhoneService 中启动 PhoneStateListener,
public void startPhoneStateListener() {
mTelManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
mTelManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
但我只在 RootReceiver 中启动服务,而不是在 MainActivity 中启动服务,当我在 MainActivity 中启动 PhoneService 时,我修复了它。
<receiver android:name=".receiver.RootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
但这只适用于 Android sdk 27 以下,我不知道 Android 9.0,顺便说一句,我已经写了权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
最佳答案
根据 Behavior Changes for all apps in Android 9.0 :
Phone numbers associated with incoming and outgoing calls are visible in the phone state broadcast, such as for incoming and outgoing calls and are accessible from the
PhoneStateListener
class. Without theREAD_CALL_LOG
permission, however, the phone number field that's provided inPHONE_STATE_CHANGED
broadcasts and throughPhoneStateListener
is empty.
如果您想要来电号码,您必须请求 READ_CALL_LOG
权限。
请注意,根据同一页面:
To read numbers from
onCallStateChanged()
, you need theREAD_CALL_LOG
permission only. You don't need theREAD_PHONE_STATE
permission.
关于android - PhoneStateListener onCallStateChanged 方法参数 "incoming number"在 Android 9.0 中为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54977469/
该特定代码块的最后一行产生错误“需要左值作为赋值的左操作数”。令人困惑的是为什么最后一行抛出此错误,而倒数第二行却没有。 int p2 = 0; spage = find(in
我想从有金额表的收入表中获取总收入金额 @ColumnInfo(name = "Amount") private int amount; 在我的 IncomeDao 中 @Query("S
我使用emsdk在Ubuntu 14.04 Docker容器上安装了Emscripten,如下所示: emsdk install emscripten-incoming emsdk install c
来自 rust 标准网络库: let listener = TcpListener::bind(("127.0.0.1", port)).unwrap(); info!("Opened socket
我将函数应用配置为期望来自客户端的证书。我今天在 Azure 门户中没有看到该选项。你知道突然发生了什么吗? 最佳答案 顺便说一句,现在该选项已移至“设置”->“配置”->“常规设置”->“需要传入证
我在 docker 容器上运行 fluentd 图像。当我使用 telnet(或 netcat)打开 TCP 连接并发送“消息”字符串时,会出现以下消息: 2017-01-24 10:22:00 +0
是否可以在可穿戴 Android 应用程序中监听传入通知?我尝试实现 NotificationListenerService,但该服务的 onNotificationPosted() 从未被调用: p
我在我的 Slack 工作区中创建了一个传入 Webhook。我正在使用第三方工具将 JSON 对象发布到 Hook url。我想向@user_1 发送通知 我的问题是通知发送到我和该用户@user_
我想在我的 Android 设备上使用 iptables 阻止所有传入连接。我知道 Google 应用程序,如 Play 商店等,需要一些传入连接(例如 GTalkSerivice),它们在阻塞后将不
我正在尝试构建一个基本数据库来帮助筛选许多 CSV 银行交易。 我已经将我所有的交易导入到多个表格中,这些表格来自不同的账户,这些账户的“扣除”列我已经勾选了“假”或“真” 我正在尝试执行“创建 Vi
这个问题在这里已经有了答案: 关闭 11 年前。
我正在使用 arduino,我想储存一些来自网络服务的字符。代码将自行解释: void loop() { static int i = 0; static int count = 0;
我可以在 Scapy 中只嗅探传入或传出数据包吗? 没有在数据包字段上添加过滤器。 最佳答案 简短的回答:没有。 Scapy 的嗅探功能不区分传入和传出数据包。如果你想根据源mac过滤,你可以这样做:
我在 J2ME 工作,想制作一个应用程序来阻止来自某些特定号码的来电。是否可以使用 J2ME 中的编程来阻止某些号码? 最佳答案 不,在 J2ME 中绝对没有办法做到这一点。 关于java - J2M
我有一个应用程序 android,它向服务器 (PC) 发送数据,但我没有收到从 PC 到应用程序的任何数据。而且,我怎样才能为传入的 UDP 消息做一个监听器? 因为我需要一个应用程序即使关闭也能一
我正在测试的单元是一个 IHostedService,它使用来自 Microsoft.Azure.ServiceBus 的 IQueueClient 进行通信。据我所知,没有像 .Receive()
IntelliJ IDEA 提供了一个 Preview Diff用于显示更改的压缩 View 的传出更改。我找不到 的等效项传入更改 .每个单个文件都必须在一个额外的窗口中与以前的修订版或本地更改进行
我正在使用连接在 10G 以太网链路上的专用硬件。我有一些关于处理传入数据报的问题,如下: 如果 NIC 发现不正确的链路级以太网 CRC 会怎样?一些搜索表明错误可能不会被可靠地报告(例如 here
我目前正在编写某种框架,允许其他人为其编写 REST Controller 。当然,我希望那些“其他人”尽可能少地与我的代码中发生的事情进行交互。 具体来说,我想要并且需要访问请求数据(即在请求由其余
我想使用 Google Drive Android API 列出和访问用户的传入项目,但我在 Drive API documentation 中找不到任何方法来执行此操作。 。我只知道如何从屏幕截图中
我是一名优秀的程序员,十分优秀!