Page 587 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 587

//  When DeviceListActivity  returns  with a device  to  connect

                                 if  (resultCode  ==  Activity.RESULT_OK) {

                                                    connectDevice(data,  true);          //연결함수  호출


                                 }

                                 break;

                            case  REQUEST_ENABLE_BT:

                                 if  (resultCode  ==  Activity.RESULT_OK) {

                                       setupChat();


                                          //  블루투스를  활성화  시켰을때..  블루투스  서비스  객체  생성

                                 } else  {

                                                    Toast.makeText(this,  "블루투스  활성화  실패",

                                                                           Toast.LENGTH_SHORT).show();

                                       finish();


                                 }

                       }

                 }

                    private  void  connectDevice(Intent  data,  boolean  secure)  {

                       // Get the  device  MAC  address


                       String address  =  data.getExtras()

                                 .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);

                       // Get the  BluetoothDevice  object

                       BluetoothDevice  device  =  mBluetoothAdapter.getRemoteDevice(address);

                                                                                           // 원격장치


                       // Attempt  to connect  to  the  device

                            Beaconservicestart.connect(device,  secure);

                                                                                              //  서비스  클래스에  정의된  연결함수  호출




                                                         -  580  -
   582   583   584   585   586   587   588   589   590   591   592