Page 450 - 2
P. 450

//import  생략

            public class MainActivity extends AppCompatActivity {
               private final String tag = "BluetoothManager";
               private final int REQUEST = 1;

               //Bluetooth Adapter
               BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
               public final static int TOAST_MESSAGE = 0;
               public final static int Image_driving = 1;
               public final static int Image_theend = 2;
               Button Connecting_button;
               Button Tmap_Button;
               Button Helmat_button, Screen_Button;
               ImageView imageView;

               Bluetooth_Manager bluetooth_manager = null;


               LocationManager locationManager;


               Start_Drive start_drive;

               BroadcastReceiver mbroBroadcastReceiver;


               private String GPS_Speed = "0";

               TextToSpeech mTTS;


               @Override
               protected void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);
                   setContentView(R.layout.activity_main);


                   if(!(ContextCompat.checkSelfPermission(this,Manifest.permission.RECEIVE_SMS)==PackageManager.PE
            RMISSION_GRANTED)){
                       String[] permissions = {Manifest.permission.RECEIVE_SMS};
                       ActivityCompat.requestPermissions(this,permissions,1);
                   }


                   mbroBroadcastReceiver = new BroadcastReceiver() {
                       @Override
                       public void onReceive(Context context, Intent intent) {
                          if("android.provider.Telephony.SMS_RECEIVED".equals(intent.getAction())){
                              Log.d("BluetoothManager1"," 메시지를 받음");
                              if(bluetooth_manager != null){
                                 if(bluetooth_manager.mmSocket.isConnected()){
                                     Bluetooth_Data data = new Bluetooth_Data();
                                     data.setMessage(" 메시지가 도착했습니다.");
                                     bluetooth_manager.Write_data(data);
                                 }


                                                         - 450 -
   445   446   447   448   449   450   451   452   453   454   455