当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothDevice.createInsecureRfcommSocketToServiceRecord方法代码示例

本文整理汇总了Java中android.bluetooth.BluetoothDevice.createInsecureRfcommSocketToServiceRecord方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothDevice.createInsecureRfcommSocketToServiceRecord方法的具体用法?Java BluetoothDevice.createInsecureRfcommSocketToServiceRecord怎么用?Java BluetoothDevice.createInsecureRfcommSocketToServiceRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.bluetooth.BluetoothDevice的用法示例。


在下文中一共展示了BluetoothDevice.createInsecureRfcommSocketToServiceRecord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure)
{
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the given BluetoothDevice
    try
    {
        if (secure)
        {
            tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE);
        }
        else
        {
            tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID_INSECURE);
        }
    }
    catch (IOException e)
    {
        MyLog.e(TAG, "Socket Type: " + mSocketType + " create() failed", e);
    }

    mmSocket = tmp;
}
 
开发者ID:Mozta,项目名称:ELM327,代码行数:26,代码来源:BluetoothIOGateway.java

示例2: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        if (secure) {
            tmp = device.createRfcommSocketToServiceRecord(
                    MY_UUID_SECURE);
        } else {
            tmp = device.createInsecureRfcommSocketToServiceRecord(
                    MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
    mState = STATE_CONNECTING;
}
 
开发者ID:AviralGarg1993,项目名称:VR-One,代码行数:22,代码来源:BluetoothListener.java

示例3: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        if (secure) {
            tmp = device.createRfcommSocketToServiceRecord(
                    MY_UUID_SECURE);
        } else {
            tmp = device.createInsecureRfcommSocketToServiceRecord(
                    MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:21,代码来源:BluetoothChatService.java

示例4: doInBackground

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... devices) //while the progress dialog is shown, the connection is done in background
{
    try
    {
        if (btSocket == null || !isBtConnected)
        {
            myBluetooth = BluetoothAdapter.getDefaultAdapter();//get the mobile bluetooth device
            BluetoothDevice dispositivo = myBluetooth.getRemoteDevice(address);//connects to the device's address and checks if it's available
            btSocket = dispositivo.createInsecureRfcommSocketToServiceRecord(myUUID);//create a RFCOMM (SPP) connection
            BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
            btSocket.connect();//start connection
        }
    }
    catch (IOException e)
    {
        ConnectSuccess = false;//if the try failed, you can check the exception here
    }
    return null;
}
 
开发者ID:mahto56,项目名称:Qeet-Remote,代码行数:21,代码来源:MainActivity.java

示例5: doInBackground

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... devices) //while the progress dialog is shown, the connection is done in background
{
    try
    {
        if (btSocket == null || !isBtConnected)
        {
            myBluetooth = BluetoothAdapter.getDefaultAdapter();//get the mobile bluetooth device
            BluetoothDevice dispositivo = myBluetooth.getRemoteDevice(address);//connects to the device's address and checks if it's available
            btSocket = dispositivo.createInsecureRfcommSocketToServiceRecord(myUUID);//create a RFCOMM (SPP) connection
            BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
            btSocket.connect();//start connection
            mmInputStream = btSocket.getInputStream();
        }
    }
    catch (IOException e)
    {
        ConnectSuccess = false;//if the try failed, you can check the exception here
    }
    return null;
}
 
开发者ID:NullPointersInc,项目名称:Bella-Android,代码行数:22,代码来源:MainActivity.java

示例6: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    try {
        if (secure) {
            tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE);
        } else {
            tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID_INSECURE);
        }
    } catch (IOException | NullPointerException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
    mState = STATE_CONNECTING;
}
 
开发者ID:zeevy,项目名称:grblcontroller,代码行数:18,代码来源:SerialThreadService.java

示例7: ClientThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ClientThread(BluetoothDevice device, Handler handler, boolean secure) {
    BluetoothSocket tempSocket = null;
    this.handler = handler;
    this.secure = secure;
    this.device = device;

    try {
        if (secure)
            tempSocket = device.createRfcommSocketToServiceRecord(UUID.fromString(Constants.UUID_STRING));
        else
            tempSocket = device.createInsecureRfcommSocketToServiceRecord(UUID.fromString(Constants.UUID_STRING));

    } catch (Exception e) {
        Log.e(TAG, e.toString());
    }
    this.socket = tempSocket;
}
 
开发者ID:n8fr8,项目名称:LittleBitLouder,代码行数:18,代码来源:ClientThread.java

示例8: ConnectionThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
/**
 * Creates the thread
 * @param playerToConnect player to connect to
 */
public ConnectionThread(Player playerToConnect) {
    //gets the device to connect to (the player's device)
    BluetoothDevice deviceToConnect = BluetoothServices.getmBluetoothAdapter().getRemoteDevice(playerToConnect.getMAC());
    System.out.println("device to connect to");
    System.out.println(deviceToConnect.getAddress());
    System.out.println(deviceToConnect.getName());
    System.out.println(deviceToConnect.toString());
    System.out.println("device to connect to");
    // Use a temporary object that is later assigned to mmSocket,
    // because mmSocket is final
    BluetoothSocket tmp = null;

    // Get a BluetoothSocket to connect with the given BluetoothDevice (that is a player)
    try {
        // MY_UUID is the app's UUID string, also used by the reception part of the code
        // creates and insecure RF socket
        tmp = deviceToConnect.createInsecureRfcommSocketToServiceRecord(MainActivity.uuid);
        System.out.println("Socket found!");

    } catch (IOException e) { }
    mmSocket = tmp;
}
 
开发者ID:mcr222,项目名称:pass_the_bomb,代码行数:27,代码来源:ConnectionThread.java

示例9: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = "Insecure";

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        tmp = device.createInsecureRfcommSocketToServiceRecord(
                    MY_UUID_INSECURE);

    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
    mState = STATE_CONNECTING;
}
 
开发者ID:alexmerz,项目名称:dab-iot,代码行数:18,代码来源:BluetoothChatService.java

示例10: doInBackground

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
    try{
        if (btSocket == null || !isBtConnected){
            myBluetooth = BluetoothAdapter.getDefaultAdapter(); //get the mobiles bluetooth
            BluetoothDevice btd = myBluetooth.getRemoteDevice(address);
            btSocket = btd.createInsecureRfcommSocketToServiceRecord(myUUID);
            BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
            btSocket.connect();
        }
    }catch(IOException e){
        ConnectionSuccess = false;
    }
    return null;
}
 
开发者ID:chooka888,项目名称:BluetoothDuck,代码行数:16,代码来源:BTTerminal.java

示例11: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device) {
    // Use a temporary object that is later assigned to mmSocket,
    // because mmSocket is final
    BluetoothSocket tmp = null;
    mmDevice = device;

    /*try {
        tmp = createBluetoothSocket(device);
    } catch (IOException e1) {
        e1.printStackTrace();
    }*/

    try {
        tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
    } catch (IOException e) { e.printStackTrace(); }

    /*try {
        tmp = createBluetoothSocket(device);
    } catch (IOException e) {
        e.printStackTrace();
    }*/

    mmSocket = tmp;
}
 
开发者ID:ordsen,项目名称:Snach-Android,代码行数:25,代码来源:BluetoothActivity.java

示例12: BluetoothClassicClient

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public BluetoothClassicClient(BluetoothDevice device, UUID uuid) {
    macAddress = device.getAddress();
    try {
        socket = device.createInsecureRfcommSocketToServiceRecord(uuid);
    } catch (IOException connectException) {
        Log.e(TAG, "Failed to set up a Bluetooth Classic connection as a client", connectException);
    }
}
 
开发者ID:aarmea,项目名称:noise,代码行数:9,代码来源:BluetoothSyncService.java

示例13: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
/**
 * Instantiates a new Connect thread.
 *
 * @param device the device
 */
public ConnectThread( BluetoothDevice device )
{
	mmDevice = device;

	BluetoothSocket tmp = null;
	if(mmDevice.getBluetoothClass() == null)
		mProtocolVer = 1;
	else if(mmDevice.getBluetoothClass().toString().equals( "51c") || mmDevice.getBluetoothClass().toString().equals( "2510"))
		mProtocolVer = 2;
	else
		mProtocolVer = 1;

	try
	{
		if(mProtocolVer == 2 && Build.VERSION.SDK_INT >= 19)
			tmp = device.createRfcommSocketToServiceRecord( NeoOne_UUID );
		else
			tmp = device.createInsecureRfcommSocketToServiceRecord( NeoOne_UUID );


	}
	catch ( Exception e )
	{
		NLog.e( "[BTAdt/ConnectThread] Socket Type : create() failed", e );
	}

	mmSocket = tmp;
}
 
开发者ID:NeoSmartpen,项目名称:AndroidSDK2.0,代码行数:34,代码来源:BTAdt.java

示例14: doInBackground

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... params) {

    try {
        if (btSocket == null || !isBtConnected) {

            bluetoothHandler.obtainMessage(BluetoothStates.BLUETOOTH_CONNECTING).sendToTarget();

            //connects to the device's address and checks if it's available
            BluetoothDevice bluetoothDevice = myBluetoothAdapter.getRemoteDevice(devicesAddress);

            //create a RFCOMM (SPP) connection
            btSocket = bluetoothDevice.createInsecureRfcommSocketToServiceRecord(myUUID);

            BluetoothAdapter.getDefaultAdapter().cancelDiscovery();

            //start connection
            btSocket.connect();
        }

    } catch (IOException e) {
        //if the try failed, you can check the exception here
        connectSuccess = false;
    }

    return null;
}
 
开发者ID:Ahmed-Abdelmeged,项目名称:Android-BluetoothMCLibrary,代码行数:28,代码来源:BluetoothMC.java

示例15: BluetoothServiceThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public BluetoothServiceThread(BluetoothService bluetoothService, BluetoothDevice bluetoothDevice) {
    this.bluetoothService = bluetoothService;

    BluetoothSocket bluetoothSocket = null;
    try {
        bluetoothSocket = bluetoothDevice.createInsecureRfcommSocketToServiceRecord(bluetoothService.getSppUuid());
    } catch (Throwable e) {
        Log.e(TAG, "could not create socket", e);
    }
    this.bluetoothSocket = bluetoothSocket;
}
 
开发者ID:journeyapps,项目名称:journey-android-bluetooth-scale,代码行数:12,代码来源:BluetoothServiceThread.java


注:本文中的android.bluetooth.BluetoothDevice.createInsecureRfcommSocketToServiceRecord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。