Keresés

Hirdetés

Új hozzászólás Aktív témák

  • shinodas

    tag

    válasz Karma #809 üzenetére

    Köszi a válaszokat! :) Azt hiszem megoldottam, már csak egy apróság :D :D (ELnézést a tényleg primitív kérdéseimért, de tényleg abszolút kezdő vagyok)
    Szóval a logcat azt mondja, h kapcsolódni próbál az eszköz de nem tudja azt befejezni, először azt írja, hogy kapcsolódva, majd 2 sorral lejjebb már ugyan ez az állapot false.

    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.UUID;

    import android.bluetooth.BluetoothAdapter;
    import android.bluetooth.BluetoothDevice;
    import android.bluetooth.BluetoothSocket;
    import android.content.Context;
    import android.os.Handler;
    import android.util.Log;


    public class BluetoothConnection extends Thread {

    private BluetoothAdapter bluetooth = null;
    private BluetoothSocket socket = null;
    private InputStream inputStream = null;
    private OutputStream outputStream = null;

    private static final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
    static final int BL_NOT_AVAILABLE = 1;
    static final int BL_SOCKET_FAILED = 2;
    protected static final int BL_INCORRECT_ADDRESS = 3;


    private Handler mHandler = null;

    public BluetoothConnection(Context context, Handler handler){
    bluetooth = BluetoothAdapter.getDefaultAdapter();
    mHandler = handler;
    if(bluetooth == null){
    mHandler.sendEmptyMessage(BL_NOT_AVAILABLE);
    return;
    }
    }

    public void BT_Connect(String Address){
    Log.d("CONNECTION", "...On Resume...");

    String address = Address;
    if(!BluetoothAdapter.checkBluetoothAddress(address)){
    return;
    }else{
    BluetoothDevice device = bluetooth.getRemoteDevice(address);
    try{
    socket = device.createRfcommSocketToServiceRecord(uuid);
    }catch(IOException e){
    Log.d("RFCOMM", "socket create fail" + e.getMessage());
    mHandler.sendEmptyMessage(BL_SOCKET_FAILED);
    return;
    }

    bluetooth.cancelDiscovery();
    [B]Log.d("BLUETOOTH", "-----CONNECTING---"); //idáig jut[/B]

    try{
    socket.connect();
    Log.d("BLUETOOTH", "Connecting is ok");
    }catch(IOException e){
    try{
    socket.close();
    }catch(IOException e2){
    Log.d("BLUETOOTH", "In onResume() and unable to close socket during connection failure" + e2.getMessage());
    mHandler.sendEmptyMessage(BL_SOCKET_FAILED);
    return;
    }
    }


    }


    }


    }

    LOGCAT:
    06-07 12:48:35.200: I/ActivityManager(231): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.hxxpd/.MainActivity } from pid 11341
    06-07 12:48:35.270: D/CONNECTION(11934): ...On Resume...
    06-07 12:48:35.280: E/BluetoothService.cpp(231): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session)
    06-07 12:48:35.280: D/BLUETOOTH(11934): -----CONNECTING---
    06-07 12:48:35.740: E/BluetoothEventLoop.cpp(231): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/10666/hci0/dev_CC_AF_78_B4_F7_6A
    06-07 12:48:35.740: D/BluetoothService(231): setRemoteDeviceProperty addr = CC:AF:78:B4:F7:6A name = Connected value = true
    06-07 12:48:37.090: D/BluetoothService(231): updateDeviceServiceChannelCache(CC:AF:78:B4:F7:6A)
    06-07 12:48:37.110: D/BluetoothService(231): uuid(system): 0000111e-0000-1000-8000-00805f9b34fb 3
    06-07 12:48:37.120: D/BluetoothService(231): uuid(system): 00001105-0000-1000-8000-00805f9b34fb 10
    06-07 12:48:37.140: V/BluetoothEventRedirector(11975): Received android.bleutooth.device.action.UUID
    06-07 12:48:37.140: D/BluetoothService(231): Cleaning up failed UUID channel lookup: CC:AF:78:B4:F7:6A 00001101-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.330: E/CachedBluetoothDevice(11975): updating profiles for JABBA
    06-07 12:48:37.330: V/CachedBluetoothDevice(11975): Class: 7e010c
    06-07 12:48:37.330: V/CachedBluetoothDevice(11975): UUID:
    06-07 12:48:37.360: V/CachedBluetoothDevice(11975): 00001000-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.390: V/CachedBluetoothDevice(11975): 00001104-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.390: V/CachedBluetoothDevice(11975): 00001105-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.390: V/CachedBluetoothDevice(11975): 00001106-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.410: V/CachedBluetoothDevice(11975): 0000110a-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.420: V/CachedBluetoothDevice(11975): 0000110b-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.420: V/CachedBluetoothDevice(11975): 0000110c-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.420: V/CachedBluetoothDevice(11975): 0000110e-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.420: V/CachedBluetoothDevice(11975): 00001112-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.440: V/CachedBluetoothDevice(11975): 00001115-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.440: V/CachedBluetoothDevice(11975): 0000111b-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.470: V/CachedBluetoothDevice(11975): 0000111e-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.470: V/CachedBluetoothDevice(11975): 0000111f-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.470: V/CachedBluetoothDevice(11975): 00001123-0000-1000-8000-00805f9b34fb
    06-07 12:48:37.470: V/CachedBluetoothDevice(11975): 0350278f-3dca-4e62-831d-a41165ff906c
    06-07 12:48:37.470: E/CachedBluetoothDevice(11975): onUuidChanged: Time since last connect67267896
    06-07 12:48:41.100: E/BluetoothEventLoop.cpp(231): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/10666/hci0/dev_CC_AF_78_B4_F7_6A
    06-07 12:48:41.100: D/BluetoothService(231): setRemoteDeviceProperty addr = CC:AF:78:B4:F7:6A name = Connected value = false
    06-07 12:48:41.330: V/BluetoothEventRedirector(11975): Received android.bleutooth.device.action.UUID
    06-07 12:48:41.350: E/CachedBluetoothDevice(11975): updating profiles for JABBA
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): Class: 7e010c
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): UUID:
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001000-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001104-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001105-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001106-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 0000110a-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 0000110b-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 0000110c-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 0000110e-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001112-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.350: V/CachedBluetoothDevice(11975): 00001115-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 0000111b-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 0000111e-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 0000111f-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 00001123-0000-1000-8000-00805f9b34fb
    06-07 12:48:41.359: V/CachedBluetoothDevice(11975): 0350278f-3dca-4e62-831d-a41165ff906c
    06-07 12:48:41.359: E/CachedBluetoothDevice(11975): onUuidChanged: Time since last connect67271789

    [ Szerkesztve ]

Új hozzászólás Aktív témák