package com.example.kj.bluetooth;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity
{
private static final int REQUEST_CONNECT_DEVICE_SECURE = 1;
private static final int REQUEST_CONNECT_DEVICE_INSECURE = 2;
private static final int REQUEST_ENABLE_BT = 3;
private BluetoothAdapter mBluetoothAdapter = null;
private BluetoothChatService mChatService = null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if(mBluetoothAdapter = null)
{
Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
finish();
return;
}
}
public void onStart()
{
super.onStart();
if(!mBluetoothAdapter.isEnabled())
{
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
}
else
{
if(mChatService = null)
{
setupChat();
}
}
}
안녕하세요 안드로이드 공부를 하고있는 학생입니다.
블루투스 예제를 책을 보고 공부하는데 빨간색으로 표시한 부분에서 에러가나서 실행이 안되네요.
에러 내용은 다음과 같습니다.
Error:(17, 13) error: cannot find symbol class BluetoothChatService
Error:(27, 30) error: incompatible types: BluetoothAdapter cannot be converted to boolean
Error:(47, 17) error: cannot find symbol method setupChat()
왜그런지 답변 부탁드리겠습니다!!