bluetooth - Send intent withing a piece of Java code -


here's piece of code of bluetooth chat:

        public void run() {         byte[] buffer;         arraylist<integer> arr_byte = new arraylist<integer>();          // keep listening inputstream while connected         while (true) {             try {                 int data = mminstream.read();                 if(data == 0x0a) {                  } else if(data == 0x0d) {                     buffer = new byte[arr_byte.size()];                     for(int = 0 ; < arr_byte.size() ; i++) {                         buffer[i] = arr_byte.get(i).bytevalue();                      }                       // send obtained bytes ui activity                     mhandler.obtainmessage(bluetoothstate.message_read                             , buffer.length, -1, buffer).sendtotarget();                     arr_byte = new arraylist<integer>();                 } else {                     arr_byte.add(data);                 }             } catch (ioexception e) {                 connectionlost();                 // start service on restart listening mode                 bluetoothservice.this.start(bluetoothservice.this.isandroid);                 break;             }         }     } 

i need send intent broadcast receiver content of buffer. i'm trying way:

            public void run() {         byte[] buffer;         arraylist<integer> arr_byte = new arraylist<integer>();          // keep listening inputstream while connected         while (true) {             try {                 int data = mminstream.read();                 if(data == 0x0a) {                  } else if(data == 0x0d) {                     buffer = new byte[arr_byte.size()];                     for(int = 0 ; < arr_byte.size() ; i++) {                         buffer[i] = arr_byte.get(i).bytevalue();                      }                      ***intent intent = new intent(data_received_intent);                      intent.putextra(data_extra, buffer);                      sendbroadcast(intent);***                       // send obtained bytes ui activity                     mhandler.obtainmessage(bluetoothstate.message_read                             , buffer.length, -1, buffer).sendtotarget();                     arr_byte = new arraylist<integer>();                 } else {                     arr_byte.add(data);                 }             } catch (ioexception e) {                 connectionlost();                 // start service on restart listening mode                 bluetoothservice.this.start(bluetoothservice.this.isandroid);                 break;             }         }     } 

i error:

cannot resolve method sendbroadcast(intent)

i understand method should defined in activity (maybe?) or it's totally incorrect way of sending intent. there way around this?


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -