Android 通过蓝牙将数据从Andread Wear Watch传输至手机

Android 通过蓝牙将数据从Andread Wear Watch传输至手机,android,wear-os,android-bluetooth,moto-360,Android,Wear Os,Android Bluetooth,Moto 360,我目前正试图通过蓝牙将一个文本文件从可穿戴设备(MOTO 360 Android 5.1.1)发送到我的手机(MOTO X Android 4.4.4),但当我执行“onSendToPhone”方法时,我在手表上收到以下错误消息: No application can handle this action public void onSendToPhone(View view) { //... // inside method // Ch

我目前正试图通过蓝牙将一个文本文件从可穿戴设备(MOTO 360 Android 5.1.1)发送到我的手机(MOTO X Android 4.4.4),但当我执行“onSendToPhone”方法时,我在手表上收到以下错误消息:

No application can handle this action
public void onSendToPhone(View view)
    {
        //...
        // inside method
        // Check if bluetooth is supported
        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();

        if (btAdapter == null) {
            // Device does not support Bluetooth
            // Inform user that we're done.
            Log.d("TAG","Bluetooth not found");
            return;
        }

        File sendFile= new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "<filename>");

        // bring up Android chooser
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(sendFile));

                startActivity(intent);
        Log.d("TAG", "File is sent via Bluetooth");
    }
也许有人能帮我找到解决办法;)

这是我用来从手表传输数据的代码:

No application can handle this action
public void onSendToPhone(View view)
    {
        //...
        // inside method
        // Check if bluetooth is supported
        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();

        if (btAdapter == null) {
            // Device does not support Bluetooth
            // Inform user that we're done.
            Log.d("TAG","Bluetooth not found");
            return;
        }

        File sendFile= new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "<filename>");

        // bring up Android chooser
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(sendFile));

                startActivity(intent);
        Log.d("TAG", "File is sent via Bluetooth");
    }
public void onSendToPhone(视图)
{
//...
//内法
//检查是否支持蓝牙
BluetoothAdapter btAdapter=BluetoothAdapter.getDefaultAdapter();
if(btAdapter==null){
//设备不支持蓝牙
//通知用户我们已经完成了。
Log.d(“标签”,“未找到蓝牙”);
返回;
}
File sendFile=新文件(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_下载)+“”;
//打开Android选择器
意图=新意图();
intent.setAction(intent.ACTION\u SEND);
intent.setType(“文本/普通”);
intent.putExtra(intent.EXTRA_流,Uri.fromFile(sendFile));
星触觉(意向);
Log.d(“标签”,“文件通过蓝牙发送”);
}

不要为此使用
蓝牙适配器。您必须使用Play服务来实现这一点

如果不想向特定节点(设备)发送文件,请查看;如果要在所有设备之间同步二进制数据,请查看