Android developers 翻訳 - android.bluetooth その2

今日は 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パーミッションが必要です。

Android developers 翻訳 - android.bluetooth

今日はbluetoothを訳してみました。ご参考までに。

・リンクなど本家サイトも並行して参照して下さい。
http://developer.android.com/intl/ja/reference/android/bluetooth/BluetoothAdapter.html
・public Methodsは抜粋して訳しています。リクエストがありましたら他のメソッドも訳します:)

        • -


BluetoothAdapter

Class Overview
Represents the local device Bluetooth adapter. The BluetoothAdapter lets you perform fundamental Bluetooth tasks, such as initiate device discovery, query a list of bonded (paired) devices, instantiate a BluetoothDevice using a known MAC address, and create a BluetoothServerSocket to listen for connection requests from other devices.
●ローカルデバイスブルートゥースアダプタを表わします。 BluetoothAdapterによって、デバイス探索開始やボンドされた(ペアになった)デバイスリストのクエリ、既知のMACアドレスを使ってBluetoothDeviceのインスタント化、他デバイスからの接続リクエストをリスンする為にBluetoothServerSocketを生成、等といった基本的なブルートゥースタスクを実行できるようになります。

To get a BluetoothAdapter representing the local Bluetooth adapter, call the static getDefaultAdapter() method. Fundamentally, this is your starting point for all Bluetooth actions. Once you have the local adapter, you can get a set of BluetoothDevice objects representing all paired devices with getBondedDevices(); start device discovery with startDiscovery(); or create a BluetoothServerSocket to listen for incoming connection requests with listenUsingRfcommWithServiceRecord(String, UUID).
●ローカルのブルートゥースアダプタを表すBluetoothAdapterを取得する為には、static のgetDefaultAdapter()メソッドをコールして下さい。基本的にこれがすべてのブルートゥースアクションの開始ポイントになります。ローカルアダプタを取得したら、getBondedDevices()によってペアになっている全ての端末を表すBluetoothDeviceオブジェクトを取得することができます。startDiscovery()でデバイス探索を開始することできますし、またlistenUsingRfcommWithServiceRecord(String,UUID)でインカミングの接続要求をリスンする為のBluetoothServerSocketを生成することができます。

Note: Most methods require the BLUETOOTH permission and some also require the BLUETOOTH_ADMIN permission.
●注意:ほとんどのメソッドでは、BLUETOOTHパーミッションが必要となります。BLUETOOTH ADMINパーミッションが必要となるものもあります。

      • -

public Set getBondedDevices ()
Since: API Level 5
Return the set of BluetoothDevice objects that are bonded (paired) to the local adapter.
Requires BLUETOOTH.
Returns
unmodifiable set of BluetoothDevice, or null on error

●ローカルアダプタにボンドされた(ペアになった)BluetoothDeviceオブジェクトをリターンします。BLUETOOTHパーミッション必要。
リターン
変更できないBluetoothDevice。エラー時はnull。

      • -

public static synchronized BluetoothAdapter getDefaultAdapter ()
Since: API Level 5
Get a handle to the default local Bluetooth adapter.
Currently Android only supports one Bluetooth adapter, but the API could be extended to support more. This will always return the default adapter.
Returns
the default local adapter, or null if Bluetooth is not supported on this hardware platform

●デフォルトのローカルブルートゥースアダプタのハンドルを取得します。
現在Androidではブルートゥースアダプタを一つだけサポートしていますが、APIはもっとサポートできるように拡張できます。常にデフォルトのアダプタをリターンします。
リターン
デフォルトのローカルアダプタ。ハードウェアプラットフォームでブルートゥースがサポートされていなければnull。

      • -

public BluetoothServerSocket listenUsingRfcommWithServiceRecord (String name, UUID uuid)
Since: API Level 5
Create a listening, secure RFCOMM Bluetooth socket with Service Record.
A remote device connecting to this socket will be authenticated and communication on this socket will be encrypted.
●リスナーを生成、安全なRFCOMMブルートゥースソケットをService Record付きで生成します。このソケットに接続してくるリモートデバイスは認証を受け、このソケット上の通信は暗号化されます。

Use accept() to retrieve incoming connections from a listening BluetoothServerSocket.
The system will assign an unused RFCOMM channel to listen on.
●BluetoothServerSocketをリスンしていて入ってくる接続を取り出すにはaccept()を使用して下さい。
システムは未使用のRFCOMMチャネルをリスン用にアサインします。

The system will also register a Service Discovery Protocol (SDP) record with the local SDP server containing the specified UUID, service name, and auto-assigned channel. Remote Bluetooth devices can use the same UUID to query our SDP server and discover which channel to connect to. This SDP record will be removed when this socket is closed, or if this application closes unexpectedly.
Use createRfcommSocketToServiceRecord(UUID) to connect to this socket from another device using the same UUID.
Requires BLUETOOTH
●システムはまた特定UUID、サービス名、自動アサインチャネルを含んだローカルSDPサーバを伴ったSDPレコード(Service Discovery Protocol record)を登録します。リモートのブルートゥースバイスはこちらのSDPサーバをクエリする為またどのチャネルに接続するかを決める為に同じUUIDを使用することができます。このソケットがクローズされた時、またはこのアプリケーションが予定外にクローズした場合にこのSDPレコードは除去されます。
他デバイスから同じUUIDでこのソケットへ接続する為にはcreateRfcommSocketToServiceRecord(UUID)を使用して下さい。
BLUETOOTHパーミッションが必要。

      • -

public boolean startDiscovery ()
Since: API Level 5
Start the remote device discovery process.
The discovery process usually involves an inquiry scan of about 12 seconds, followed by a page scan of each new device to retrieve its Bluetooth name.
●リモートデバイスの探索プロセスを開始します。
探索プロセスには、通常約12秒の問い合わせスキャンがあり、次にそれぞれの新規デバイスブルートゥース名を探す為のページスキャンがあります。

This is an asynchronous call, it will return immediately. Register for ACTION_DISCOVERY_STARTED and ACTION_DISCOVERY_FINISHED intents to determine exactly when the discovery starts and completes. Register for ACTION_FOUND to be notified as remote Bluetooth devices are found.
●非同期コールでありすぐにリターンされます。ACTION_DISCOVERY_STARTED, ACTION_DISCOVERY_FINISHEDの登録は厳密にいつ探索が開始されたか完了したかを知る為のものです。ACTION_FOUNDを登録すると、リモートブルートゥースバイスが見つけられた時に通知されます。

Device discovery is a heavyweight procedure. New connections to remote Bluetooth devices should not be attempted while discovery is in progress, and existing connections will experience limited bandwidth and high latency. Use cancelDiscovery() to cancel an ongoing discovery. Discovery is not managed by the Activity, but is run as a system service, so an application should always call cancelDiscovery() even if it did not directly request a discovery, just to be sure.
●デバイス探索は重い処理です。探索中リモートブルートゥースバイスへの新規接続は試みるべきではなく、既存の接続ではバンド幅が限定されたり長い遅延になります。実行中の探索をキャンセルするにはcancelDiscovery()を使用して下さい。探索はActivityによって管理されるものではなく、システムのサービスとして実行されます。よってアプリケーションは直接探索をリクエストしていなくても常にcancelDiscovery()をコールするべきです。念のため。

Device discovery will only find remote devices that are currently discoverable (inquiry scan enabled). Many Bluetooth devices are not discoverable by default, and need to be entered into a special mode.
Requires BLUETOOTH_ADMIN.
●デバイス探索では現在discoverable(問い合わせスキャンenabled)のリモートデバイスのみを見つけます。ブルートゥースバイスの多くはデフォルトでdiscoverableではなく、特別なモードに入ることが必要になります。
BLUETOOTH_ADMINパーミッションが必要。

Download the Android SDK − Android SDKをダウンロードする

注意)以下の日本語訳はkaopadがメモ代わりに残しているものです。
   ご参照の際は個人の責任の下、ご利用下さい。

December 2009
The Android SDK has changed! If you've worked with the Android SDK before, you will notice several important differences:
show more:
●2009年12月
Android SDKが変わりました!今までのAndroid SDKをお使いなら、今回何点か重要な変更に気づくでしょう。
show more割愛。。。

If you are new to the Android SDK, please read the Quick Start, below, for an overview of how to install and set up the SDK.
●初めてAndroid SDKをダウンロードするなら、下記のQuick Startをお読みになり、SDKのインストール、セットアップ方法について概要をつかんで下さい。

Quick Start
The steps below provide an overview of how to get started with the Android SDK. For detailed instructions, start with the Installing guide.
●Quick Start
以下のステップではAndroid SDKをどうやって始めるかの概要を説明します。詳細な説明はInstallingガイドを参照下さい。

0. Prepare your development computer

Read the System Requirements document and make sure that your development computer meets the hardware and software requirements for the Android SDK. Install any additional software needed before downloading the Android SDK. In particular, if you plan to develop Android applications in the Eclipse IDE using the ADT Plugin (see below), make sure that you have the correct version of Eclipse installed.
●0. 開発用コンピュータの準備
システムリクワイアメントを読んで、開発マシンがAndroid SDKのハード・ソフトリクワイアメントを満たしていることを確認して下さい。Android SDKをダウンロードする前に追加の必要なソフトをインストールして下さい。特にADTプラグインを使ってEclipse統合開発環境(下記参照)でAndroidアプリを開発する予定なら、正しいバージョンのEclipseがインストールされていることを確認下さい。

1. Download and install the SDK starter package

Select a starter package from the table at the top of this page and download it to your development computer. To install the SDK, simply unpack the starter package to a safe location and then add the location to your PATH.
●1. SDKスターターパッケージのダウンロード・インストール
本ページトップのテーブルからスターターパッケージを選択して開発マシンへダウンロードして下さい。SDKをインストールする為には単にスターターパッケージを安全な場所(ロケーション)に解凍して、PATHにそのロケーションを追加してください。

2. Install the ADT Plugin for Eclipse

If you are developing in Eclipse, set up a remote update site and install the Android Development Tools (ADT) plugin. For detailed instructions, see Installing and Updating ADT.
●2. Eclipse用ADTプラグインのインストール
Eclipseで開発しているなら、リモート更新サイトを準備し、Android Development Tools(ADT)プラグインをインストールして下さい。詳細な
手順はInstalling and Updating ADTを参照下さい。

3. Add Android platforms to your SDK

Use the Android SDK and AVD Manager, included in the SDK starter package, to add one or more Android platforms (for example, Android 1.6 or Android 2.0) to your SDK. In most cases, you will want to download multiple platforms, so that you can build your application on the lowest version you want to support, but test against higher versions that you intend the application to run on. Information about each platform is available at left, under "Downloadable SDK Components."

To launch the Android SDK and AVD Manager on Windows, execute SDK Setup.exe, at the root of the SDK directory. On Mac OS X or Linux, execute the android tool in the /tools/ folder. For more information about how to add platforms and other components, see Adding SDK Components.
●3. SDKAndroidプラットフォームを追加
SDKスターターパッケージに含まれるAndroid SDK and AVD Managerを使って、
一つ以上のAndroidプラットフォーム(例えばAndroid1.6と2.0)をSDKに追加して下さい。サポートしたい最低バージョンでアプリをビルドし、アプリを実行するつもりのより高いバージョンでテストができるように、大抵の場合は複数プラットフォームのダウンロードをお勧めします。それぞれのプラットフォームに関する情報は左記"Downloadable SDK Components."配下から利用可能です。
WindowsAndroid SDK and AVD Manager を起動するにはSDKディレクトリ直下でSDK Setup.exeを実行して下さい。Mac OS X or Linuxでは、/tools/フォルダでandroid toolを実行して下さい。プラットフォーム追加や他のコンポーネント追加についての更なる情報はAdding SDK Componentsを参照下さい。

4. Get the latest documentation

If you develop while offline, use the Android SDK and AVD Manager to download the latest documentation package. The documentation covers all versions of the API and lets you filter out those versions that your application won't support. Once installed, the documentation is also available to you directly from the Eclipse IDE.
●4. 最新ドキュメントの入手
開発中オフラインの時の為、Android SDK and AVD Manager を使って最新ドキュメントパッケージをダウンロードして下さい。このドキュメントではすべてのパージョンのAPIをカバーしており、あなたのアプリがサポートしないバージョンをフィルターすることもできます。インストールが完了すると、ドキュメントはEclipseIDEから直接利用可能です。

5. Download other SDK components

You can use the Android SDK and AVD Manager to download other SDK components, such as the SDK add-ons. An SDK add-on provides a development environment for an Android external library or a customized Android system image. For example, the Google APIs Add-On lets you develop an application that takes advantage of the Google Maps external library.
●5. 他のSDKコンポーネントのダウンロード
Android SDK and AVD Manager を使って他のSDKコンポーネント、例えばSDKアドオンなどをダウンロードできます。SDKアドオンはAndroid外部ライブラリの開発環境を提供したりカスタマイズしたAndroidシステムイメージを提供します。例えば、Google APIsアドオンで、Google Maps外部ライブラリを利用するアプリの開発ができるようになります。

6. Get started with an application project

Once you've set up your SDK, the next step is to start a new application project or move existing applications into the new SDK.

If you are new to Android, you can use the Hello World tutorial to get started quickly. Next Steps offers other suggestions of how to begin. Welcome!
●6. アプリプロジェクトを始めましょう
SDKのセットアップが終了したら、次のステップは新しいアプリプロジェクトを開始するか、既存アプリをSDKに移動するかです。
Androidが始めてなら、手っ取り早く始めるのにはHello World チュートリアルを使ってみることができます。Next Steps には開始方法のお勧めが記載されています。