本文整理汇总了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;
}