Android O无法接收广播Intent.ACTION_NEW_OUTGOING_CALL [英] Android O can't receive broadcast Intent.ACTION_NEW_OUTGOING_CALL
问题描述
在我的应用程序中,我可以在 android O 上收到android.intent.action.PHONE_STATE
,但不能收到Intent.ACTION_NEW_OUTGOING_CALL
.如果我使用 android N 或 android M ,一切正常.
In my application, I can receive android.intent.action.PHONE_STATE
but can't receive Intent.ACTION_NEW_OUTGOING_CALL
on android O. If I use android N or android M everything work fine.
我先在 AndroidManifest文件中注册了广播,然后在前景服务中注册了第二广播,但是他们都无法接收Intent.ACTION_NEW_OUTGOING_CALL
,只能接收android.intent.action.PHONE_STATE
.
I have register first broadcast in AndroidManifest file and second in foreground service, but none of them can receive Intent.ACTION_NEW_OUTGOING_CALL
, only can receive android.intent.action.PHONE_STATE
.
如果有人知道如何解决它,请发表您的答案,在此先感谢.
If anyone know how to fix it, please post your answer, thanks in advance.
推荐答案
但是我仍然感到困惑,因为我的电话不要求我允许但可以正常工作.也许是Android O的错误或功能?
But I am still confused, because my phone not ask me to give the permission but work fine. Maybe a bug or feature of android O ?
它是Android O的功能.
Its a feature of Android O.
以前,当您请求权限组(PHONE
)的权限(android.permission.READ_PHONE_STATE
)并且用户授予该权限时,您可以使用该权限组(android.permission.PROCESS_OUTGOING_CALLS
等)的任何权限. c5>)(无需再次请求用户).
Previously, when you request a permission (android.permission.READ_PHONE_STATE
) of a permission group (PHONE
) and the user grants it, you are allowed to use any permission (android.permission.PROCESS_OUTGOING_CALLS
etc.) of that permission group (PHONE
) freely(without requesting to user again).
现在从Android O开始,即使您的应用程序已经拥有权限组(PHONE
)的权限(android.permission.READ_PHONE_STATE
),也需要再次调用requestPermission
以获得同一组的其他权限(android.permission.PROCESS_OUTGOING_CALLS
) .这不会提示用户授予权限(android.permission.PROCESS_OUTGOING_CALLS
),如果您已经拥有同一权限组(PHONE
)的另一个权限(android.permission.READ_PHONE_STATE
),则将自动授予该权限.
Now from Android O, even if your app already holds permission (android.permission.READ_PHONE_STATE
) of a permission group(PHONE
), you need to call requestPermission
again for other permission (android.permission.PROCESS_OUTGOING_CALLS
) of the same group. This will not prompt user to grant permission(android.permission.PROCESS_OUTGOING_CALLS
) and the permission will automatically be granted if you already hold another permission (android.permission.READ_PHONE_STATE
) of same permission group(PHONE
).
这篇关于Android O无法接收广播Intent.ACTION_NEW_OUTGOING_CALL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!