آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

ارسال پیام به وسیله بلوتوث

jafarmazareei  10 سال پیش  10 سال پیش
0 0

سلام. دوستان کسی هست که بدونه چطور میشه بین دو گوشی بوسیله بلوتوث پیام ارسال کرد؟ اموزش چت رو هم نگاه کردم ولی نتونستم. ممنون میشم کسی جواب بده

 برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال 
Hossein Lamei Ramandi  10 سال پیش
0 0

یه سرچی تو استک میزدی پیدا میکردی :

 
privateOutputStream outputStream;
private
InputStream inStream;
private
void init() throws IOException{BluetoothAdapter blueAdapter =BluetoothAdapter.getDefaultAdapter();
if
(blueAdapter !=null){
if(blueAdapter.isEnabled()){
Set
<BluetoothDevice> bondedDevices = blueAdapter.getBondedDevices();
if(bondedDevices.size()>0){BluetoothDevice[] devices =(BluetoothDevice[]) bondedDevices.toArray();
BluetoothDevice
device = devices[0];
ParcelUuid
[] uuids = device.getUuids();
BluetoothSocket
socket = device.createRfcommSocketToServiceRecord(uuids[0].getUuid()); socket.connect(); outputStream = socket.getOutputStream(); inStream = socket.getInputStream();
}
Log.e("error","No appropriate paired devices.");
}
else{Log.e("error","Bluetooth is disabled.");
}
}
}
publicvoid write(String s)throwsIOException{ outputStream.write(s.getBytes());
}
publicvoid run(){
finalint BUFFER_SIZE =1024;
byte
[] buffer =newbyte[BUFFER_SIZE];
int
bytes =0;int b = BUFFER_SIZE;
while
(true){
try{ bytes = inStream.read(buffer, bytes, BUFFER_SIZE - bytes);
}catch(IOException e){ e.printStackTrace();}}}

پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .