小编Bao*_*Hoa的帖子

无法连接到 VPN 中的本地服务器

我在多个 iOS、MacOS 中尝试过以下代码。

这是服务器代码

void *run_server(void *thread_id) {
    int server_fd, new_socket;
    struct sockaddr_in server, client;
    int opt = 1;
    int addrlen = sizeof(server);
   
    // Creating socket file descriptor
    if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
        perror("socket");
        return NULL;
    }

    // Forcefully attaching socket to the port
    if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))) {
        perror("setsockopt");
        return NULL;
    }

    server.sin_family = AF_INET;
    server.sin_addr.s_addr = ip("10.10.10.20"); // bind IP
    server.sin_port = htons(27042);
   
    // Forcefully attaching socket to the port
    if (bind(server_fd, …
Run Code Online (Sandbox Code Playgroud)

sockets ip vpn network-programming server

8
推荐指数
1
解决办法
68
查看次数

警告:不允许使用广告密钥“服务数据”

我正在开发 BLE 外设应用程序。根据要求,广告包中必须包含Service Data字段。我在Android中做到了这一点,数据包应该是这样的:

在此输入图像描述

0x16 是此处列出的服务数据字段https://www.bluetooth.com/specifications/signed-numbers/generic-access-profile/

同样的事情,我在 iOS 中也是这样做的。我使用BluetoothCore框架来实现蓝牙外设。

以下是我应该用来设置服务数据字段值的属性:

advertisementData[CBAdvertisementDataServiceDataKey] = <somedata>
Run Code Online (Sandbox Code Playgroud)

但是我收到了警告:

警告:不允许使用广告密钥“服务数据”

有人可以告诉我为什么以及解决方案是什么吗?

ios core-bluetooth bluetooth-lowenergy ios-bluetooth

6
推荐指数
1
解决办法
2076
查看次数

JNI IsSameObject 方法在 Android 13 中返回错误值

目的是将字节数组与 NULL 值进行比较

jmethodID midGet = (*env)->GetMethodID(env, classArrayList, "get", "(I)Ljava/lang/Object;");
jbyteArray arr = (*env)->CallObjectMethod(env, arrayList, midGet, 0);
if (!(*env)->IsSameObject(env, arr, NULL)) {
    // Always falls in here when testing with Android 13
    // For Android <13, this block is not executed
}
Run Code Online (Sandbox Code Playgroud)

arrayList是从Java层传入的

ArrayList<byte[]> arrayList = new ArrayList<>();
arrayList.add(null);
Run Code Online (Sandbox Code Playgroud)

IsSameObject 方法在 Android 13 中返回意外值。请帮我弄清楚。谢谢!

java java-native-interface android

5
推荐指数
0
解决办法
146
查看次数

您请求的商品无法购买 - 应用内结算

我有一个测试Android计费的麻烦!谁来帮帮我!我举个例子:

主要活动

public class MainActivity extends Activity {
    IabHelper mHelper;

    IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory){
            if (result.isFailure()) {
                // handle error
                Toast.makeText(getApplicationContext(), "debug: Query occur error!", Toast.LENGTH_SHORT).show();
                return;
            }

            if (result.isSuccess()) {
                Toast.makeText(getApplicationContext(), "debug: Query successfully!", Toast.LENGTH_SHORT).show();
                Toast.makeText(getApplicationContext(), "debug: " + inventory.getSkuDetails("product_1").getTitle(), Toast.LENGTH_SHORT).show();
                Toast.makeText(getApplicationContext(), "debug: " + inventory.getSkuDetails("product_2").getTitle(), Toast.LENGTH_SHORT).show();
                return;
            }
        }
    };

    IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
        public void onIabPurchaseFinished(IabResult result, Purchase purchase)
        {
            if (result.isFailure()) {
                Toast.makeText(getApplicationContext(), "debug: purcharge failed", …
Run Code Online (Sandbox Code Playgroud)

mobile android in-app-billing

4
推荐指数
1
解决办法
3046
查看次数