如何解决在本地使用 Java AlertDialog
我正在开发一个使用 NearbyConnection API 的 react-native 应用程序。 我不希望自动接受连接。 用户应该能够接受或拒绝连接。 我尝试了谷歌提出的代码(代码如下)
new AlertDialog.Builder(context)
.setTitle("Accept connection to " + info.getEndpointName())
.setMessage("Confirm the code matches on both devices: " + info.getAuthenticationDigits())
.setPositiveButton(
"Accept",(DialogInterface dialog,int which) ->
// The user confirmed,so we can accept the connection.
Nearby.getConnectionsClient(context)
.acceptConnection(endpointId,payloadCallback))
.setNegativeButton(
"Refuse",int which) ->
// The user canceled,so we should reject the connection.
Nearby.getConnectionsClient(context).rejectConnection(endpointId))
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
但它不起作用(应用程序在此级别崩溃)。 有没有办法重写此代码以与 reat-native 兼容? 或者是否可以执行一个 JS 函数并在 Java 中得到结果?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。