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.