简体   繁体   中英

Data Transfer from Andread Wear Watch to phone via bluetooth

I'm currently trying to send a textfile from the wearable (MOTO 360 Android 5.1.1) to my phone (Moto X Android 4.4.4) via bluetooth, but when i execute the "onSendToPhone" method I get the following error message on the watch:

No application can handle this action

Maybe someone can help me and find a solution ;)

This is the code I use to transfer data from the watch:

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");
    }

Don't use a BluetoothAdapter for that. You have to use the Play Services to do that.

Take a look at the ChannelAPI if you wan't to send a file to a particular node (device) or at the DataLayer if you want to synchronize binary data between all the devices.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM