當前位置: 首頁>>代碼示例>>Java>>正文


Java BluetoothServerSocket類代碼示例

本文整理匯總了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;

}
 
開發者ID:n8fr8,項目名稱:LittleBitLouder,代碼行數:17,代碼來源:ServerThread.java

示例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;
}
 
開發者ID:Alex-Jerry,項目名稱:BleDemo,代碼行數:21,代碼來源:BluetoothSPPService.java

示例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;
}
 
開發者ID:Mozta,項目名稱:ELM327,代碼行數:25,代碼來源:BluetoothIOGateway.java

示例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;
}
 
開發者ID:AviralGarg1993,項目名稱:VR-One,代碼行數:20,代碼來源:BluetoothListener.java

示例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;
}
 
開發者ID:NeoSmartpen,項目名稱:AndroidSDK2.0,代碼行數:22,代碼來源:BTAdt.java

示例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;
}
 
開發者ID:tkmarsh,項目名稱:SmartRC,代碼行數:19,代碼來源:BluetoothChatService.java

示例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);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:24,代碼來源:DroidtoothPlugin.java

示例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;
}
 
開發者ID:zeevy,項目名稱:grblcontroller,代碼行數:18,代碼來源:SerialThreadService.java

示例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;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:19,代碼來源:BluetoothChatService.java

示例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;
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:11,代碼來源:AcceptThread.java

示例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;
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:22,代碼來源:BluetoothManager.java

示例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;
}
 
開發者ID:yoxin,項目名稱:pet,代碼行數:18,代碼來源:BluetoothChatService.java

示例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;
}
 
開發者ID:tiagohm,項目名稱:BlueDroid,代碼行數:22,代碼來源:BlueService.java

示例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;
}
 
開發者ID:NeoSmartpen,項目名稱:AndroidSDK,代碼行數:18,代碼來源:BTAdt.java

示例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;
}
 
開發者ID:shensky711,項目名稱:Run-With-You,代碼行數:18,代碼來源:BluetoothControlerImpl.java


注:本文中的android.bluetooth.BluetoothServerSocket類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。