当前位置: 首页>>代码示例>>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;未经允许,请勿转载。