android java.lang.SecurityException: Permission Denial: not allowed to send broadcast

发送的时候添加了一个权限,所以广播接收的时候也要需要权限,才能接收到,不然就会报上面的异常

在广播的注册中文件中添加权限,如下:

<receiver android:name="com.hoperun.phone.OutgoingCallBroadcaster$OutgoingCallReceiver" android:permission="android.permission.PROCESS_OUTGOING_CALLS">
            <intent-filter>
                <action android:name="nihaoma" />
            </intent-filter>
        </receiver>

红色的部分是必须的,否则接收不到


原文地址:https://www.cnblogs.com/nizuimeiabc1/p/4254263.html