【问题标题】:Send an object from a java application to an Android application via Bluetooth?通过蓝牙将对象从 java 应用程序发送到 Android 应用程序?
【发布时间】:2016-06-16 23:20:27
【问题描述】:

我需要通过蓝牙将运行在笔记本电脑上的 java 应用程序中的对象发送到 Android 设备。类如下:

public class Contact {
    private static int counter = 0;
    private int id;
    private String firstName;
    private String lastName;
    private String email;

    public Contact(String firstName, String lastName, String email) {
        this.id = ++counter;
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = email;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public String getEmail() {
        return email;
    }
}

我不知道使用什么库或 API 来发送数据。我认为,首先,我必须配对两个设备,但我也不知道该怎么做。配对后,我认为我的 Android 应用程序中应该有一个在接收到数据时执行的侦听器,不是吗?

我希望你能帮助我,因为我完全卡住了。

提前致谢。

【问题讨论】:

    标签: java android bluetooth


    【解决方案1】:

    如果您想将运行 Java 应用程序的笔记本电脑中的数据发送到 Android 设备,请查看this question。另外,我建议使用后端框架通过 Web 服务在 Android 应用程序之间共享数据。

    【讨论】:

    • 谢谢@Alberto。我会强烈考虑使用网络服务而不是这种方法,因为我很痛苦地无法使用蓝牙来解决。
    猜你喜欢
    • 1970-01-01
    • 2017-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多