Bluetooth'a genel bakış
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Android platformu, bir cihazın diğer Bluetooth cihazlarla kablosuz olarak veri alışverişinde bulunmasına olanak tanıyan Bluetooth ağ yığınını destekler. Uygulama çerçevesi, Bluetooth API'leri üzerinden Bluetooth işlevlerine erişim sağlar. Bu API'ler, uygulamaların diğer Bluetooth cihazlara bağlanarak noktadan noktaya ve çok noktalı kablosuz bağlantı özelliklerine sahip olmasını sağlar.
Bir uygulama, Bluetooth API'larını kullanarak aşağıdakileri gerçekleştirebilir:
- Diğer Bluetooth cihazları tarayın.
- Eşlenen Bluetooth cihazlar için yerel Bluetooth adaptörünü sorgulayın.
- RFCOMM kanalları oluşturun.
- Hizmet keşfi üzerinden diğer cihazlara bağlanma
- Diğer cihazlara/cihazlardan veri aktarın.
- Birden fazla bağlantıyı yönetin.
Bu konu Klasik Bluetooth ile ilgilidir. Klasik Bluetooth, cihazlar arasında akış ve iletişim gibi pil yoğun işlemler için doğru seçenektir. Güç gereksinimleri düşük olan Bluetooth cihazlar için Bluetooth Düşük Enerji bağlantılarını kullanabilirsiniz.
Bu dokümanlarda farklı Bluetooth profilleri açıklanmakta ve Bluetooth kullanarak iletişim kurmak için gerekli dört temel görevi gerçekleştirmek üzere Bluetooth API'larının nasıl kullanılacağı açıklanmaktadır:
- Bluetooth kuruluyor.
- Eşlenen veya yerel bölgede kullanılabilen cihazlar bulunuyor.
- Cihazlar bağlanıyor.
- Cihazlar arasında veri aktarımı.
Bluetooth API'lerinin kullanımıyla ilgili bir tanıtım için Bluetooth Chat örnek uygulamasını inceleyin.
Temel bilgiler
Bluetooth özellikli cihazların birbirleri arasında veri iletebilmesi için öncelikle bir eşleme işlemi kullanarak iletişim kanalı oluşturmaları gerekir. Bulunabilir bir cihaz olan bir cihaz, gelen bağlantı istekleri için kendisini kullanılabilir hale getirir.
Başka bir cihaz, hizmet keşif işlemi kullanarak bulunabilir cihazı bulur.
Bulunabilir cihaz eşleme isteğini kabul ettikten sonra, iki cihaz güvenlik anahtarı alışverişinde bulundukları bağlanma sürecini tamamlar. Cihazlar bu anahtarları daha sonra kullanmak üzere önbelleğe alır. Eşleme ve bağlama işlemleri tamamlandıktan sonra iki cihaz bilgi alışverişinde bulunur. Oturum tamamlandığında, eşleme isteğini başlatan cihaz, kendisini bulunabilir cihaza bağlayan kanalı serbest bırakır. Bununla birlikte, iki cihaz birbirine bağlı kalır ve böylece gelecekteki oturumlarda birbirlerinin kapsama alanında oldukları ve iki cihaz da bağı kaldırmadığı sürece otomatik olarak yeniden bağlanabilirler.
Bluetooth API'lerinin kullanılması için manifest dosyanızda çeşitli izinleri beyan etmeniz gerekir. Uygulamanızın Bluetooth kullanma izni olduğunda, uygulamanızın BluetoothAdapter
'a erişmesi ve cihazda Bluetooth'un kullanılabilir olup olmadığını belirlemesi gerekir.
Bluetooth kullanılabiliyorsa üç adımda bağlantı kurabilirsiniz:
Bazı cihazlar, sağladığı verileri açıklayan özel bir Bluetooth profili kullanır.
Anahtar sınıfları ve arayüzler
Tüm Bluetooth API'leri android.bluetooth
paketinde bulunur.
Bluetooth bağlantıları oluşturmak için ihtiyacınız olan sınıflar ve arayüzler şunlardır:
BluetoothAdapter
- Yerel Bluetooth adaptörünü (Bluetooth radyo) temsil eder.
BluetoothAdapter
, tüm Bluetooth etkileşimleri için giriş noktasıdır. Bu işlevi kullanarak diğer Bluetooth cihazlarını keşfedebilir, bağlı (eşlenmiş) cihazların listesini sorgulayabilir, bilinen bir MAC adresi kullanarak BluetoothDevice
oluşturabilir ve diğer cihazlardan gelen iletişimleri dinlemek için bir BluetoothServerSocket
oluşturabilirsiniz.
BluetoothDevice
- Uzak bir Bluetooth cihazını temsil eder.
BluetoothSocket
aracılığıyla bir uzaktan cihazla bağlantı isteğinde bulunmak veya cihazla ilgili ad, adres, sınıf ve bağlanma durumu gibi bilgileri sorgulamak için bunu kullanın.
BluetoothSocket
- Bluetooth soketinin arayüzünü temsil eder (TCP
Socket
'ye benzer). Bu bağlantı noktası bir uygulamanın InputStream
ve OutputStream
kullanarak başka bir Bluetooth cihazıyla veri alışverişinde bulunmasına olanak tanır.
BluetoothServerSocket
- Gelen istekleri dinleyen açık bir sunucu yuvasını temsil eder (TCP
ServerSocket
'ye benzer). İki cihazı bağlamak için bir cihazın bu sınıfla bir sunucu yuvasını açması gerekir. Uzak bir Bluetooth cihazı bu cihaza bağlantı isteğinde bulunduğunda, cihaz bağlantıyı kabul eder ve ardından bağlı bir BluetoothSocket
döndürür.
BluetoothClass
- Bluetooth cihazların genel özelliklerini ve işlevlerini açıklar.
Bu, cihazın sınıflarını ve hizmetlerini tanımlayan salt okunur bir özellik grubudur. Bu bilgiler bir cihazın türüyle ilgili yararlı ipuçları sağlasa da, bu sınıfın özellikleri her zaman cihazın desteklediği tüm Bluetooth profillerini ve hizmetlerini açıklamayabilir.
BluetoothProfile
- Bluetooth profilini temsil eden bir arayüz. Bluetooth profili, cihazlar arasında Bluetooth tabanlı iletişim için kullanılan kablosuz bir arayüz özelliğidir. Eller Serbest profili buna örnek olarak gösterilebilir. Profillerle ilgili daha fazla açıklama için Bluetooth profilleri konusuna bakın.
BluetoothHeadset
- Cep telefonlarıyla kullanılmak üzere Bluetooth kulaklıklar için destek sağlar. Buna hem Bluetooth Mikrofonlu Kulaklık profili hem de Eller Serbest (v1.5) profili dahildir.
BluetoothA2dp
- Gelişmiş Ses Dağıtım Profili (A2DP) kullanılarak Bluetooth bağlantısı üzerinden bir cihazdan diğerine nasıl yüksek kalitede ses aktarılabileceğini tanımlar.
BluetoothHealth
- Bluetooth hizmetini kontrol eden Sağlık Cihazı Profili proxy'sini temsil eder.
BluetoothHealthCallback
BluetoothHealth
geri çağırma işlevini uygulamak için kullandığınız soyut bir sınıf. Uygulamanın kayıt durumu ve Bluetooth kanal durumundaki değişikliklerle ilgili güncellemeleri almak için bu sınıfı genişletmeniz ve geri çağırma yöntemlerini uygulamanız gerekir.
BluetoothHealthAppConfiguration
- Bluetooth Sağlık üçüncü taraf uygulamasının uzak bir Bluetooth sağlık cihazıyla iletişim kurmak için kaydettiği bir uygulama yapılandırmasını temsil eder.
BluetoothProfile.ServiceListener
- Belirli bir profili çalıştıran dahili hizmete bağlanıldıklarında veya bağlantıları kesildiğinde
BluetoothProfile
arası iletişim (IPC) istemcilerini bilgilendiren bir arayüz.
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-26 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-07-26 UTC."],[],[],null,["# Bluetooth overview\n\nThe Android platform includes support for the Bluetooth network stack, which\nallows a device to wirelessly exchange data with other Bluetooth devices. The\napp framework provides access to the Bluetooth functionality through Bluetooth\nAPIs. These APIs let apps connect to other Bluetooth devices, enabling\npoint-to-point and multipoint wireless features.\n\nUsing the Bluetooth APIs, an app can perform the following:\n\n- Scan for other Bluetooth devices.\n- Query the local Bluetooth adapter for paired Bluetooth devices.\n- Establish RFCOMM channels.\n- Connect to other devices through service discovery.\n- Transfer data to and from other devices.\n- Manage multiple connections.\n\nThis topic focuses on *Classic Bluetooth* . Classic Bluetooth is the right choice\nfor more battery-intensive operations, which include streaming and communicating\nbetween devices. For Bluetooth devices with low power requirements, consider\nusing [Bluetooth Low Energy](/develop/connectivity/bluetooth/ble-overview)\nconnections.\n\nThis documentation describes different Bluetooth\n[profiles](/develop/connectivity/bluetooth/profiles) and explains how to\nuse the Bluetooth APIs to accomplish the four major tasks necessary to\ncommunicate using Bluetooth:\n\n- Setting up Bluetooth.\n- Finding devices that are either paired or available in the local area.\n- Connecting devices.\n- Transferring data between devices.\n\nFor a demonstration of using the Bluetooth APIs, see the [Bluetooth Chat sample\napp](https://github.com/android/connectivity-samples/tree/master/BluetoothChat).\n\nThe basics\n----------\n\nFor Bluetooth-enabled devices to transmit data between each other, they must\nfirst form a channel of communication using a pairing process. One device, a\ndiscoverable device, makes itself available for incoming connection requests.\nAnother device finds the discoverable device using a service discovery process.\nAfter the discoverable device accepts the pairing request, the two devices\ncomplete a bonding process in which they exchange security keys. The devices\ncache these keys for later use. After the pairing and bonding processes are\ncomplete, the two devices exchange information. When the session is complete,\nthe device that initiated the pairing request releases the channel that had\nlinked it to the discoverable device. The two devices remain bonded, however, so\nthey can reconnect automatically during a future session as long as they're in\nrange of each other and neither device has removed the bond.\n\nUse of the Bluetooth APIs requires\n[declaring several permissions](/develop/connectivity/bluetooth/bt-permissions#declare)\nin your manifest file. Once your app has permission to use Bluetooth, your app\nneeds to access the\n[`BluetoothAdapter`](/reference/android/bluetooth/BluetoothAdapter) and\n[determine if Bluetooth is available on the device](/develop/connectivity/bluetooth/setup).\nIf Bluetooth is available, there are three steps to make a connection:\n\n- [Find nearby Bluetooth\n devices](/develop/connectivity/bluetooth/find-bluetooth-devices), either devices that are already paired or new ones.\n- [Connect to a Bluetooth\n device](/develop/connectivity/bluetooth/connect-bluetooth-devices).\n- [Transfer data with the connected\n device](/develop/connectivity/bluetooth/transfer-data).\n\nCertain devices use a specific [Bluetooth\nprofile](/develop/connectivity/bluetooth/profiles) that declares the data\nit provides.\n\nKey classes and interfaces\n--------------------------\n\nAll of the Bluetooth APIs are available in the\n[`android.bluetooth`](/reference/android/bluetooth/package-summary) package.\nThe following are the classes and interfaces you need in order to create\nBluetooth connections:\n\n[`BluetoothAdapter`](/reference/android/bluetooth/BluetoothAdapter)\n: Represents the local Bluetooth adapter (Bluetooth radio). The\n `BluetoothAdapter` is the entry-point for all Bluetooth interaction. Using\n this, you can discover other Bluetooth devices, query a list of bonded\n (paired) devices, instantiate a\n `BluetoothDevice` using a known MAC address, and create a\n `BluetoothServerSocket` to listen for communications from other devices.\n\n[`BluetoothDevice`](/reference/android/bluetooth/BluetoothDevice)\n: Represents a remote Bluetooth device. Use this to request a connection with a\n remote device through a `BluetoothSocket` or query information about the\n device such as its name, address, class, and bonding state.\n\n[`BluetoothSocket`](/reference/android/bluetooth/BluetoothSocket)\n: Represents the interface for a Bluetooth socket (similar to a TCP\n [`Socket`](/reference/java/net/Socket)). This is the connection point that\n allows an app to exchange data with another Bluetooth device using\n [`InputStream`](/reference/java/io/InputStream) and\n [`OutputStream`](/reference/java/io/OutputStream).\n\n[`BluetoothServerSocket`](/reference/android/bluetooth/BluetoothServerSocket)\n: Represents an open server socket that listens for incoming requests (similar\n to a TCP [`ServerSocket`](/reference/java/net/ServerSocket)). In order to\n connect two devices, one device must open a server socket with this\n class. When a remote Bluetooth device makes a connection request to this\n device, the device accepts the connection and then returns a connected\n `BluetoothSocket`.\n\n[`BluetoothClass`](/reference/android/bluetooth/BluetoothClass)\n: Describes the general characteristics and capabilities of a Bluetooth device.\n This is a read-only set of properties that defines the device's classes and\n services. Although this information provides a useful hint regarding a\n device's type, the attributes of this class don't necessarily describe all\n Bluetooth profiles and services that the device supports.\n\n[`BluetoothProfile`](/reference/android/bluetooth/BluetoothProfile)\n: An interface that represents a Bluetooth profile. A Bluetooth profile is a\n wireless interface specification for Bluetooth-based communication between\n devices. An example is the Hands-Free profile. For more discussion of\n profiles, see [Bluetooth profiles](/develop/connectivity/bluetooth/profiles).\n\n[`BluetoothHeadset`](/reference/android/bluetooth/BluetoothHeadset)\n: Provides support for Bluetooth headsets to be used with mobile phones. This\n includes both the Bluetooth Headset profile and the Hands-Free (v1.5) profile.\n\n[`BluetoothA2dp`](/reference/android/bluetooth/BluetoothA2dp)\n: Defines how high-quality audio can be streamed from one device to another over\n a Bluetooth connection using the Advanced Audio Distribution Profile (A2DP).\n\n[`BluetoothHealth`](/reference/android/bluetooth/BluetoothHealth)\n: Represents a Health Device Profile proxy that controls the Bluetooth service.\n\n[`BluetoothHealthCallback`](/reference/android/bluetooth/BluetoothHealthCallback)\n: An abstract class that you use to implement `BluetoothHealth` callbacks. You\n must extend this class and implement the callback methods to receive updates\n about changes in the app's registration state and Bluetooth channel\n state.\n\n[`BluetoothHealthAppConfiguration`](/reference/android/bluetooth/BluetoothHealthAppConfiguration)\n: Represents an app configuration that the Bluetooth Health third-party\n app registers to communicate with a remote Bluetooth health device.\n\n[`BluetoothProfile.ServiceListener`](/reference/android/bluetooth/BluetoothProfile.ServiceListener)\n: An interface that notifies `BluetoothProfile` interprocess communication (IPC)\n clients when they have been connected to or disconnected from the internal\n service that runs a particular profile."]]