Android developers 翻訳 - android.bluetoothããã®ï¼
ä»æ¥ã¯ãBluetoothServerSocket, BluetoothSocket ã訳ãã¦ã¿ã¾ããã
次ã¯ä½ã訳ããããªã»ã»ã»ãªã¯ã¨ã¹ãåéä¸ã
Androidæè¼ç«¯æ«(MID)ãæ¢ãä¸ãsmartq5ããç»é¢ã大ããã¦ããæé ãªãã
-
-
-
- -
-
-
BluetoothServerSocket
Class Overview
A listening Bluetooth socket.
The interface for Bluetooth Sockets is similar to that of TCP sockets: Socket and ServerSocket. On the server side, use a BluetoothServerSocket to create a listening server socket. When a connection is accepted by the BluetoothServerSocket, it will return a new BluetoothSocket to manage the connection. On the client side, use a single BluetoothSocket to both intiate an outgoing connection and to manage the connection.
The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs. RFCOMM is a connection-oriented, streaming transport over Bluetooth. It is also known as the Serial Port Profile (SPP).
âãªã¹ã³ããå´ã®ãã«ã¼ãã¥ã¼ã¹ã½ã±ããã
ãã«ã¼ãã¥ã¼ã¹ã½ã±ããã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¯TCPã½ã±ããã«é¡ä¼¼ãã¦ãã¾ããããªãã¡Socketã¨ServerSocketãããµã¼ããµã¤ãã§ã¯ããªã¹ãã³ã°ãµã¼ãã½ã±ãããçæããçºã«BluetoothServerSocketã使ç¨ãã¦ä¸ãããBluetoothServerSocketã§æ¥ç¶ãã¢ã¯ã»ãããããããBluetoothServerSocketã¯æ¥ç¶ã管çããçºã«æ°ããBluetoothSocketããªã¿ã¼ã³ãã¾ããã¯ã©ã¤ã¢ã³ããµã¤ãã§ã¯ãæ¥ç¶ãéå§ããçºãæ¥ç¶ã管çããçºã®ä¸¡æ¹ã«ä¸ã¤ã®BluetoothSocketã使ç¨ãã¦ä¸ããã
ãã«ã¼ãã¥ã¼ã¹ã½ã±ããã®ã¿ã¤ãã¨ãã¦æãä¸è¬çãªã®ã¯RFCOMMã§ãAndroid APIã§ãµãã¼ããããã¿ã¤ãã§ããRFCOMMã¯æ¥ç¶ãªãªã¨ã³ãããã§ãã«ã¼ãã¥ã¼ã¹ä¸ã§ã®ã¹ããªã¼ãã³ã°éä¿¡ã§ããã¾ãSerial Port Profile (SPP)ã¨ãã¦ãç¥ããã¦ãã¾ãã
To create a listenting BluetoothServerSocket that's ready for incoming connections, use BluetoothAdapter.listenUsingRfcommWithServiceRecord(). Then call accept() to listen for incoming connection requests. This call will block until a connection is established, at which point, it will return a BluetoothSocket to manage the connection. Once the BluetoothSocket is acquired, it's a good idea to call close() on the BluetoothServerSocket when it's no longer needed for accepting connections. Closing the BluetoothServerSocket will not close the returned BluetoothSocket.
BluetoothServerSocket is thread safe. In particular, close() will always immediately abort ongoing operations and close the server socket.
Note: Requires the BLUETOOTH permission.
âã¤ã³ã«ãã³ã°ãªæ¥ç¶ã«æºåãæ´ã£ããªã¹ãã³ã°BluetoothServerSocketãçæããçºã«ã¯ãBluetoothAdapter.listenUsingRfcommWithServiceRecord()ã使ç¨ãã¦ä¸ãããããã¦ãã¤ã³ã«ãã³ã°ã®æ¥ç¶ãªã¯ã¨ã¹ãããªã¹ã³ããçºã«ã¯accept()ãã³ã¼ã«ãã¦ä¸ããããã®ã³ã¼ã«ã¯æ¥ç¶ã確ç«ãããã¾ã§ã¯ãããã¯ãã¾ããæ¥ç¶ç¢ºç«æã«ã¯ãæ¥ç¶ç®¡çã®çºã«BluetoothSocketããªã¿ã¼ã³ãã¾ããBluetoothSocketãåå¾ã§ããããBluetoothServerSocketã®close()ãã³ã¼ã«ããã®ãè¯ãã§ããæ¥ç¶ãã¢ã¯ã»ããããå¿
è¦ãããã¾ããã®ã§ãBluetoothServerSocketãã¯ãã¼ãºãã¦ããªã¿ã¼ã³ãããBluetoothSocketã¯ã¯ãã¼ãºããã¾ããã
BluetoothServerSocketã¯ã¹ã¬ããã»ã¼ãã§ããç¹ã«ãclose()ã¯å¸¸ã«å³åº§ã«åä½ä¸ã®å¦çãä¸æ¢ãããµã¼ãã¼ã½ã±ãããã¯ãã¼ãºãã¾ãã
注æï¼BLUETOOTHãã¼ããã·ã§ã³ãå¿
è¦ã§ãã
-
-
-
- -
-
-
BluetoothSocket
Class Overview
A connected or connecting Bluetooth socket.
The interface for Bluetooth Sockets is similar to that of TCP sockets: Socket and ServerSocket. On the server side, use a BluetoothServerSocket to create a listening server socket. When a connection is accepted by the BluetoothServerSocket, it will return a new BluetoothSocket to manage the connection. On the client side, use a single BluetoothSocket to both intiate an outgoing connection and to manage the connection.
The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs. RFCOMM is a connection-oriented, streaming transport over Bluetooth. It is also known as the Serial Port Profile (SPP).
âæ¥ç¶ããããã¾ãã¯æ¥ç¶ãããã¨ãã¦ããå´ã®ãã«ã¼ãã¥ã¼ã¹ã½ã±ããã
ãã«ã¼ãã¥ã¼ã¹ã½ã±ããã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¯TCPã½ã±ããã«é¡ä¼¼ãã¦ãã¾ããããªãã¡Socketã¨ServerSocketãããµã¼ããµã¤ãã§ã¯ããªã¹ãã³ã°ãµã¼ãã½ã±ãããçæããçºã«BluetoothServerSocketã使ç¨ãã¦ä¸ãããBluetoothServerSocketã§æ¥ç¶ãã¢ã¯ã»ãããããããBluetoothServerSocketã¯æ¥ç¶ã管çããçºã«æ°ããBluetoothSocketããªã¿ã¼ã³ãã¾ããã¯ã©ã¤ã¢ã³ããµã¤ãã§ã¯ãæ¥ç¶ãéå§ããçºãæ¥ç¶ã管çããçºã®ä¸¡æ¹ã«ä¸ã¤ã®BluetoothSocketã使ç¨ãã¦ä¸ããã
ãã«ã¼ãã¥ã¼ã¹ã½ã±ããã®ã¿ã¤ãã¨ãã¦æãä¸è¬çãªã®ã¯RFCOMMã§ãAndroid APIã§ãµãã¼ããããã¿ã¤ãã§ããRFCOMMã¯æ¥ç¶ãªãªã¨ã³ãããã§ããã«ã¼ãã¥ã¼ã¹ä¸ã§ã®ã¹ããªã¼ãã³ã°éä¿¡ã§ããã¾ãSerial Port Profile (SPP)ã¨ãã¦ãç¥ããã¦ãã¾ãã
To create a BluetoothSocket for connecting to a known device, use BluetoothDevice.createRfcommSocketToServiceRecord(). Then call connect() to attempt a connection to the remote device. This call will block until a connection is established or the connection fails.
To create a BluetoothSocket as a server (or "host"), see the BluetoothServerSocket documentation.
Once the socket is connected, whether initiated as a client or accepted as a server, open the IO streams by calling getInputStream() and getOutputStream() in order to retrieve InputStream and OutputStream objects, respectively, which are automatically connected to the socket.
BluetoothSocket is thread safe. In particular, close() will always immediately abort ongoing operations and close the socket.
Note: Requires the BLUETOOTH permission.
âæ¢ç¥ããã¤ã¹ã¸ã®æ¥ç¶ç¨BluetoothSocketãçæããçºã«ã¯ãBluetoothDevice.createRfcommSocketToServiceRecord()ã使ç¨ãã¦ä¸ãããããã¦ããªã¢ã¼ãããã¤ã¹ã¸ã®æ¥ç¶ã試ã¿ãã«ã¯connect()ãã³ã¼ã«ãã¦ä¸ããããã®ã³ã¼ã«ã¯æ¥ç¶ã確ç«ãããã¾ã§ã¾ãã¯æ¥ç¶ã失æããã¾ã§ãããã¯ãã¾ãã
ãµã¼ã(ãã¹ã)ã¨ãã¦BluetoothSocketãçæããã«ã¯ãBluetoothServerSocketãåç
§ä¸ããã
ã¯ã©ã¤ã¢ã³ããéå§ãã¾ãã¯ãµã¼ããã¢ã¯ã»ããã©ã¡ãã®å ´åã§ãã½ã±ãããæ¥ç¶ããããªããInputStream,OutputStreamãªãã¸ã§ã¯ããåå¾ããçºã«getInputStream()ã¨getOutputStream()ãã³ã¼ã«ãã¦IOã¹ããªã¼ã ããããããªã¼ãã³ãã¦ä¸ããããããã¯ã½ã±ããã«èªåçã«æ¥ç¶ããã¦ãããã®ã§ãã
BluetoothServerSocketã¯ã¹ã¬ããã»ã¼ãã§ããç¹ã«ãclose()ã¯å¸¸ã«å³åº§ã«åä½ä¸ã®å¦çãä¸æ¢ãããµã¼ãã¼ã½ã±ãããã¯ãã¼ãºãã¾ãã
注æï¼BLUETOOTHãã¼ããã·ã§ã³ãå¿
è¦ã§ãã