简体   繁体   English

Activity onPause()之前的BroadcastReceiver?

[英]BroadcastReceiver before Activity onPause()?

When I am on an Activity and an incoming call is coming, I would like to send a parameter from the BroadCastReceiver that receives the call to the Activity before the onPause() starts. 当我处于Activity上且即将有来电时,我想从BroadCastReceiver发送一个参数,该参数在onPause()启动之前接收对Activity的调用。 Is it possible ? 可能吗 ? Could you suggest me an alternative ? 你能建议我替代吗?

In my tests, the Activity.onPause() starts always before the BroadCastReceiver. 在我的测试中,Activity.onPause()始终在BroadCastReceiver之前启动。

I've tried to use an internal BroadcastReceiver in my Activity and an external one but I can't achieve this. 我曾尝试在Activity中使用内部的BroadcastReceiver和外部的,但是我无法实现。

Here is a little schema of my problem. 这是我的问题的一些示意图。

在此处输入图片说明

Thanks 谢谢

Did you try to use TelephonyManager to listen the PhoneStateListener for linstening the phone state change ? 您是否尝试使用TelephonyManager侦听PhoneStateListener来阻止电话状态更改?

 onCallStateChanged(int state, String incomingNumber)

Callback invoked when device call state changes. 设备调用状态更改时调用回调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM