本文整理匯總了Java中android.bluetooth.BluetoothServerSocket類的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothServerSocket類的具體用法?Java BluetoothServerSocket怎麽用?Java BluetoothServerSocket使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BluetoothServerSocket類屬於android.bluetooth包,在下文中一共展示了BluetoothServerSocket類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ServerThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public ServerThread(BluetoothAdapter adapter, Handler handler, boolean secure) {
this.handler = handler;
BluetoothServerSocket tempSocket = null;
try {
if (secure)
tempSocket = adapter.listenUsingRfcommWithServiceRecord(Constants.NAME, UUID.fromString(Constants.UUID_STRING));
else
tempSocket = adapter.listenUsingInsecureRfcommWithServiceRecord(Constants.NAME, UUID.fromString(Constants.UUID_STRING));
} catch (IOException ioe) {
Log.e(TAG, ioe.toString());
}
serverSocket = tempSocket;
}
示例2: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(boolean secure)
{
//Tmp變量
BluetoothServerSocket tmp = null;
//初始化類型
mSocketType = secure ? "Secure":"Insecure";
// 創建一個服務的Listener
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
示例3: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(boolean secure)
{
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try
{
if (secure)
{
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
}
else
{
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
}
catch (IOException e)
{
MyLog.e(TAG, "Listen to " + mSocketType + " socket type failed. More: ", e);
}
mmServerSocket = tmp;
}
示例4: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
mState = STATE_LISTEN;
}
示例5: setNewServerSocket
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
/**
* Sets new server socket.
*/
public void setNewServerSocket()
{
BluetoothServerSocket tmp = null;
try
{
if(mProtocolVer == 2)
tmp = mAdapter.listenUsingRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
else
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
NLog.d( "[BTAdt] ListenThread new BT ServerSocket assigned" );
}
catch ( IOException e )
{
NLog.e( "[BTAdt] ListenThread new BT ServerSocket assign fail", e );
}
mmServerSocket = tmp;
}
示例6: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
示例7: createKeyAgreementListener
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
@Override
public KeyAgreementListener createKeyAgreementListener(byte[] commitment) {
if (!isRunning()) return null;
// There's no point listening if we can't discover our own address
String address = AndroidUtils.getBluetoothAddress(appContext, adapter);
if (address.isEmpty()) return null;
// No truncation necessary because COMMIT_LENGTH = 16
UUID uuid = UUID.nameUUIDFromBytes(commitment);
if (LOG.isLoggable(INFO)) LOG.info("Key agreement UUID " + uuid);
// Bind a server socket for receiving invitation connections
BluetoothServerSocket ss;
try {
ss = adapter.listenUsingInsecureRfcommWithServiceRecord(
"RFCOMM", uuid);
} catch (IOException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
BdfList descriptor = new BdfList();
descriptor.add(TRANSPORT_ID_BLUETOOTH);
descriptor.add(StringUtils.macToBytes(address));
return new BluetoothKeyAgreementListener(descriptor, ss);
}
示例8: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException | NullPointerException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
mState = STATE_LISTEN;
}
示例9: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
示例10: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(Context context, BluetoothAdapter mBluetoothAdapter, AcceptInterface acceptInterface) {
BluetoothServerSocket tmp = null;
this.acceptInterface = acceptInterface;
try {
tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(context.getPackageName(), Utility.uuid);
} catch (IOException e) {
e.printStackTrace();
}
serverSocket = tmp;
}
示例11: ListeningThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
/**
* コンストラクタ
* @param secure セキュア接続を待機するならtrue
*/
public ListeningThread(final boolean secure) {
super("ListeningThread:" + mName);
// Create a new listening server socket
BluetoothServerSocket tmp = null;
try {
if (secure) {
// セキュアな接続を行うためのBluetoothServerSocketを生成
tmp = mAdapter.listenUsingRfcommWithServiceRecord(mName, mSecureProfileUUID);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(mName, mInSecureProfileUUID);
}
} catch (final IOException e) {
Log.w(TAG, e);
}
mmServerSocket = tmp;
}
示例12: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
}
mmServerSocket = tmp;
}
示例13: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public AcceptThread(boolean isAndroid, boolean secure) {
BluetoothServerSocket tmp = null;
try {
if (secure) {
if (isAndroid)
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
else
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
} else {
if (isAndroid)
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
else
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
}
} catch (IOException e) {
e.printStackTrace();
}
mmServerSocket = tmp;
}
示例14: setNewServerSocket
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
public void setNewServerSocket()
{
BluetoothServerSocket tmp = null;
try
{
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
//tmp = mAdapter.listenUsingRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
NLog.d( "[BTAdt] ListenThread new BT ServerSocket assigned" );
}
catch ( IOException e )
{
NLog.e( "[BTAdt] ListenThread new BT ServerSocket assign fail", e );
}
mmServerSocket = tmp;
}
示例15: AcceptThread
import android.bluetooth.BluetoothServerSocket; //導入依賴的package包/類
AcceptThread(boolean secure, int timeout) {
BluetoothServerSocket tmp = null;
this.mSecure = secure;
this.mTimeout = timeout;
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + getSocketType(secure) + "listen() failed", e);
}
mmServerSocket = tmp;
}