Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

bluetooth chat example android server

Thread {
            bluetoothAdapter?.startDiscovery()
            val server : BluetoothServerSocket? = bluetoothAdapter?.listenUsingRfcommWithServiceRecord("Bluetooth", uuid)
            var loop = true
            while (loop) {
                Log.d("Server", "Printing")
                val bluetoothSocket: BluetoothSocket? = try {
                    server?.accept()
                } catch (e: IOException) {
                    Log.e("ServerSocket", "Socket's accept() failed", e)
                    e.printStackTrace()
                    null
                }
                bluetoothSocket?.let {
                    binder.socketConnectedCallback?.onSocketConnected(it)
                }
                server?.close()
                loop = false
            }
        }.start()
Comment

bluetooth chat example android client

Thread {
                val bluetoothSocket = device.device.createRfcommSocketToServiceRecord(uuid)
                bluetoothAdapter?.cancelDiscovery()
                val succeeded = try {
                    bluetoothSocket?.connect()
                    device.socket = bluetoothSocket
                    true
                } catch (e: Exception) {
                    e.printStackTrace()
                    false
                }
                Handler(Looper.getMainLooper()).post {
                    onFinished.invoke(succeeded)
                }
            }.start()
Comment

PREVIOUS NEXT
Code Example
Java :: spring core xml configuration for collection using constructor 
Java :: Give the output of the following code: int a = 10; int b = 20; String s = Integer.toString(a); String t = Integer.toString(b); System.out.println((s+t)); 
Java :: getcokor from drawable in java android studio 
Java :: hide frame ( acces to the top level component ) 
Java :: start/php2 
Java :: logger output to console twice java 
Java :: search for a string in byte array 
Java :: draw an icon in between swiped area android 
Java :: Change or Replace ArrayList Elements using set() function 
Java :: Deal with empty or blank cell in excel file using apache poi 
Java :: java inetaddress workaround how to get localhost secure 
Java :: EuclideanAlgorithm in Java 
Java :: Java Arraylist bestimmtes element ausgeben 
Java :: Append Line Separator In StringBuilder 
Java :: springBoot Disable a Specific Auto-Configuration 
Java :: check whether an entry in hashmap is deleted in java 
Java :: change FS to hdfs java 
Java :: system program j 
Java :: quadratic program 
Java :: determine the distance between two circles in java 
Java :: choose image java 
Java :: java map get value 
Java :: what is method overriding in java 
Java :: += in java 
Java :: java indexof not found 
Java :: java @override 
Java :: log4j2.properties file need to save in spring boot application 
Java :: Access HashMap Elements 
Java :: $950 at 6% per annum for three years. 
Java :: Fab to CircularRevealFrameLayout example 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =