亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Verzeichnis suchen
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
Figuren


BluetoothSocket

版本:Android 2.3 r1

?

結(jié)構(gòu)

繼承關(guān)系

public final class BluetoothSocket extends Object implements Closeable

????????

java.lang.Object

android.bluetooth.BluetoothSocket

?

類(lèi)概述

???????? 已連接或連接到藍(lán)牙套接字(socket)

???????? 藍(lán)牙端口監(jiān)聽(tīng)接口和TCP端口類(lèi)似:SocketServerSocket類(lèi)。在服務(wù)器端,使用BluetoothServerSocket類(lèi)來(lái)創(chuàng)建一個(gè) 監(jiān)聽(tīng)服務(wù)端口。當(dāng)一個(gè)連接被BluetoothServerSocket所接受,它會(huì)返回一個(gè)新的BluetoothSocket來(lái)管理該連接。在客戶 端,使用一個(gè)單獨(dú)的BluetoothSocket類(lèi)去初始化一個(gè)外接連接和管理該連接。

最通常使用的藍(lán)牙端口是RFCOMM,它是被Android API支持的類(lèi)型。RFCOMM是一個(gè)面向連接,通過(guò)藍(lán)牙模塊進(jìn)行的數(shù)據(jù)流傳輸方式,它也被稱為串行端口規(guī)范(Serial Port Profile,SPP)。

為了創(chuàng)建一個(gè)BluetoothSocket去連接到一個(gè)已知設(shè)備,使用方法 BluetoothDevice.createRfcommSocketToServiceRecord()。然后調(diào)用connect()方法去嘗試一個(gè) 面向遠(yuǎn)程設(shè)備的連接。這個(gè)調(diào)用將被阻塞指導(dǎo)一個(gè)連接已經(jīng)建立或者該鏈接失效。

為了創(chuàng)建一個(gè)BluetoothSocket作為服務(wù)端(或者主機(jī)),查看BluetoothServerSocket文檔。

每當(dāng)該端口連接成功,無(wú)論它初始化為客戶端,或者被接受作為服務(wù)器端,通過(guò)getInputStream()getOutputStream()來(lái)打開(kāi)IO流,從而獲得各自的InputStreamOutputStream對(duì)象

BluetoothSocket類(lèi)線程安全。特別的,close()方法總會(huì)馬上放棄外界操作并關(guān)閉服務(wù)器端口。

注意:需要BLUETOOTH權(quán)限。

參見(jiàn)

???????? BluetoothServerSocket

??? InputStream

??? OutputStream

?

公共方法

??? public void close ()

馬上關(guān)閉該端口并且釋放所有相關(guān)的資源。

在其它線程的該端口中引起阻塞,從而使系統(tǒng)馬上拋出一個(gè)IO異常。

異常

IOException

?

??? public void connect ()

嘗試連接到遠(yuǎn)程設(shè)備。

該方法將阻塞,指導(dǎo)一個(gè)連接建立或者失效。如果該方法沒(méi)有返回異常值,則該端口現(xiàn)在已經(jīng)建立。

當(dāng)設(shè)備查找正在進(jìn)行的時(shí)候,創(chuàng)建對(duì)遠(yuǎn)程藍(lán)牙設(shè)備的新連接不可被嘗試。在藍(lán)牙適配器上,設(shè)備查找是一個(gè)重量級(jí)過(guò)程,并且肯定會(huì)降低一個(gè)設(shè)備的連接。使用 cancelDiscovery()方法去取消一個(gè)外界的查詢。查詢并不由活動(dòng)所管理,而作為一個(gè)系統(tǒng)服務(wù)來(lái)運(yùn)行,所以即使它不能直接請(qǐng)求一個(gè)查詢,應(yīng)用 程序也總會(huì)調(diào)用cancelDiscovery()方法。

close()方法可以用來(lái)放棄從另一線程而來(lái)的調(diào)用。

異常

IOException???? 一個(gè)錯(cuò)誤,例如連接失敗。

?

??? public InputStream getInputStream ()

通過(guò)連接的端口獲得輸入數(shù)據(jù)流

即使該端口未連接,該輸入數(shù)據(jù)流也會(huì)返回。不過(guò)在該數(shù)據(jù)流上的操作將拋出異常,直到相關(guān)的連接已經(jīng)建立。

返回值

輸入流

異常

IOException

?

??? public OutputStream getOutputStream ()

通過(guò)連接的端口獲得輸出數(shù)據(jù)流

即使該端口未連接,該輸出數(shù)據(jù)流也會(huì)返回。不過(guò)在該數(shù)據(jù)流上的操作將拋出異常,直到相關(guān)的連接已經(jīng)建立。

返回值

輸出流

異常

IOException

?

??? public BluetoothDevice getRemoteDevice ()

獲得該端口正在連接或者已經(jīng)連接的遠(yuǎn)程設(shè)備。

返回值

遠(yuǎn)程設(shè)備

?

補(bǔ)充

??? 文章精選

??????? 第四十一講:Android藍(lán)牙編程入門(mén)

??????? Android藍(lán)牙APIBluetoothSocket類(lèi)

??????? Android藍(lán)牙APIBluetoothSocket類(lèi)(2)

?

?


Vorheriger Artikel: N?chster Artikel: