【问题标题】:How to use OBEX/Bluecove with Android如何在 Android 上使用 OBEX/Bluecove
【发布时间】:2012-06-19 20:54:19
【问题描述】:

我的任务是通过蓝牙以编程方式共享文件。我尝试使用 stackoverflow 提供的几个示例。但它无法识别确切的解决方案。让我知道如何在 android 上使用 OBEX api。

我尝试使用 android 实现 Bluecove jar,我在构建路径中添加了 jar,当我运行应用程序时,它显示错误,例如 - BlueCove native library version mismatch 您能提供解决此问题的必要解决方案吗? 当我使用 loadlibrary 时,它通常指出 javax.bluetooth.BluetoothStateException: BlueCove 原生库版本不匹配。

帮我解决这个问题。

提前致谢。

【问题讨论】:

    标签: android


    【解决方案1】:

    一种简单的方法是使用现有应用程序通过 BT 发送文件(共享功能是 Android 的架构目标之一)。安装一个应用(在playstore中搜索蓝牙)并使用类似于以下的方法发送您的文件:

    private File exportFile;  // set when creating the file
    
    /**
     * Send the export file via an intent with the send action.
     */
    private void doSendFile() {
        final Intent i = new Intent(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(this.exportFile));
        i.setType("text/*");
        final Intent chooser = Intent.createChooser(i, this.global.getText(R.string.txt_send_chooser_title));  // R.string.... is the label's ID for the chooser headline
        chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.startActivity(chooser);
    }
    

    【讨论】:

    • @Stefan..我也知道通过这种方法共享的方式..我想本地共享一个文件。你能给我一个想法,让他在不使用意图的情况下实现同样的功能吗?
    • 不,我不这样做,因为我决定重用现有组件,这节省了我很多时间。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-01
    • 2018-07-11
    • 2021-10-03
    • 2016-02-28
    • 2014-06-29
    • 1970-01-01
    相关资源
    最近更新 更多