0

皆さん、こんにちは。本当の問題に直面しています。Bluetooth経由でテキスト情報を送信するarduinoデバイスを持っています。Androidフォンでこのテキストを受信したいのですが、反応の前に((text))を確認したいです。

SMS ((BroadcastReceiver)) のようにそれを行う方法はありますか

public class Receiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        }
    }
4

1 に答える 1

0

正確にそれを行う方法がわかりません。ただし、Receiver for SMSを使用するのと同じ方法で、ReceiverforBluetoothを使用できます。

受信者の登録(マニフェストまたはコード内)

registerReceiver(ActionFoundReceiver, new IntentFilter(
            BluetoothDevice.ACTION_FOUND));

そして受信機を定義する

    private final BroadcastReceiver ActionFoundReceiver = new BroadcastReceiver() {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        String action = intent.getAction();
        if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            BluetoothDevice device = intent
                    .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

        String name;
            name = device.getName();

        }
    }
};

私は推測します:コミュニケーションであなたはあなたにテキストを与える意図で別の乳母車を捕まえることができます。

いくつかの例が必要な場合は、見てください。 http://android-er.blogspot.com.es/2011/05/scan-bluetooth-devices.html および http://luugiathuy.com/2011/02/android-java-bluetooth/

于 2012-07-23T12:42:51.050 に答える