0

谁能告诉我我的代码有什么问题?

startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE), DISCOVERY_REQUEST);

    @Override
    protected void onActivityResult(int requestCode,int resultCode, Intent data)
    { 
        if (requestCode == DISCOVERY_REQUEST) 
        {
            boolean isDiscoverable = resultCode > 0;
            int discoverableDuration = resultCode;
            if (isDiscoverable) 
            {
                UUID uuid = UUID.fromString("a60f35f0-b93a-11de-8a39-08002009c666");
                String name = "bluetoothserver";
                final BluetoothServerSocket btserver = bt.listenUsingRfcommWithServiceRecord(name, uuid);
                Thread acceptThread = new Thread(new Runnable() {
                public void run()
                {
                    try
                    {
                        BluetoothSocket serverSocket = btserver.accept();
                    }
                    catch (Exception e)
                    {
                        Log.d("BLUETOOTH", e.getMessage());
                    }
                }
                });
                acceptThread.start();
            }
        }
    }

在此代码中,它在onActivityResult显示错误。

4

0 回答 0