Boolean::class.java 在从信号 R 接收数据并传递给广播接收器时无法转换为布尔值 (java)
Boolean::class.java can not cast to boolean (java) when receive data from Signal R and pass to broadcast receiver
我是 Android 开发人员,我使用 Signal R 与服务器通信并在从服务器发出时获取数据:
hubConnection.on(
Constants.SIGNALR_TARGET_RECEIVE_CALL_REQUEST,
{ receiveCallRequestDetails, isVideoEnable ->
intent.putExtra(BROADCAST_SIGNAL_R_RECEIVE_CALL_REQUEST_DETAILS, receiveCallRequestDetails)
intent.putExtra(BROADCAST_SIGNAL_R_RECEIVE_CALL_REQUEST_IS_VIDEO, isVideoEnable)
LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(intent)
// applicationContext.sendBroadcast(intent)
},
ReceiveCallRequest::class.java,
Boolean::class.java
)
当我从服务器获取布尔值(isVideoEnable 是布尔值)并将其传递给 BroadcastReceiver 时,我得到了 RunTimeError,其描述如下:
HubConnection disconnected with
WebSocket connection stopping with code null and reason 'Cannot cast java.lang.Boolean to boolean'.
通常应该可以,但您可以将其从布尔值(对象类型)更改为布尔值(原始类型)。
我是 Android 开发人员,我使用 Signal R 与服务器通信并在从服务器发出时获取数据:
hubConnection.on(
Constants.SIGNALR_TARGET_RECEIVE_CALL_REQUEST,
{ receiveCallRequestDetails, isVideoEnable ->
intent.putExtra(BROADCAST_SIGNAL_R_RECEIVE_CALL_REQUEST_DETAILS, receiveCallRequestDetails)
intent.putExtra(BROADCAST_SIGNAL_R_RECEIVE_CALL_REQUEST_IS_VIDEO, isVideoEnable)
LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(intent)
// applicationContext.sendBroadcast(intent)
},
ReceiveCallRequest::class.java,
Boolean::class.java
)
当我从服务器获取布尔值(isVideoEnable 是布尔值)并将其传递给 BroadcastReceiver 时,我得到了 RunTimeError,其描述如下:
HubConnection disconnected with WebSocket connection stopping with code null and reason 'Cannot cast java.lang.Boolean to boolean'.
通常应该可以,但您可以将其从布尔值(对象类型)更改为布尔值(原始类型)。