Sends an object through bluetooth. - Android Bluetooth

Android examples for Bluetooth:Bluetooth Data Transfer

Description

Sends an object through bluetooth.

Demo Code


//package com.java2s;

import java.io.ObjectOutputStream;

import android.bluetooth.BluetoothSocket;

public class Main {
    /**// www.  jav a2  s .c  o  m
     * Sends an object through bluetooth.
     */
    public static boolean bluetoothWriteObject(Object object,
            BluetoothSocket socket) {
        try {
            ObjectOutputStream oOS = new ObjectOutputStream(
                    socket.getOutputStream());
            oOS.writeObject(object);
            oOS.flush();
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}

Related Tutorials