0
私は、チップからAndroidの携帯電話にデータを転送するBluetooth機能を使用するアンドロイドアプリケーションを開発しようとしています。私はコードを開発者のウェブサイト上のチュートリアルから変更していません。チップからBluetooth経由でデータを転送するにはどうすればよいですか?
私は、次のエラーを取得しています:ここで
_context cannot be resolved as a variable
は私のコードです:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocalBluetoothDevice localBT = LocalBluetoothDevice.initLocalDevice(_context);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
W私はこれを試してみましたが、initLocalDeviceがプロジェクトのメインアクティビティであるタイプLocalBluetoothDevice – YoKaGe
に対して定義されていないというエラーが出ましたか?あなたはContext context = YourMainActivity.thisを実行し、それを使用する必要があります – Suchi
私はあなたが答えることができるかどうか疑問に思っていたいくつかのより多くの質問がありますか? – YoKaGe