Receives an object through bluetooth. - Android Bluetooth

Android examples for Bluetooth:Bluetooth Data Transfer

Description

Receives an object through bluetooth.

Demo Code


//package com.java2s;
import java.io.ObjectInputStream;

import android.bluetooth.BluetoothSocket;

public class Main {
    /**//w  w w  .j  a va 2s .  co m
     * Receives an object through bluetooth.
     */
    public static Object bluetoothReadObject(BluetoothSocket socket) {
        ObjectInputStream oIS;
        try {
            oIS = new ObjectInputStream(socket.getInputStream());
            Object object = oIS.readObject();
            return object;
        } catch (Exception e) {
            return null;
        }
    }
}

Related Tutorials