Hello Mina,
Every time the device sends a file over I get "java.io.IOException:
File descriptor in bad state". The file is a binary file with custom
extension. Am I missing something? My code is below:
UUID OBEX_OBJECT_PUSH = new UUID("xxxx....", false);
SessionNotifier serverConnection = null;
LocalDevice localDevice;
try
{
localDevice = LocalDevice.getLocalDevice();
if (!localDevice.setDiscoverable(DiscoveryAgent.GIAC))
{
Log.e(Constant.TAG, TAG + "Fail to set LocalDevice
Discoverable");
}
final String url = "btgoep://localhost:" +
OBEX_OBJECT_PUSH +
";name=myapp;authenticate=false;master=false;encrypt=false;android=true";
serverConnection = (SessionNotifier) Connector.open(url);
final ServiceRecord record =
localDevice.getRecord(serverConnection);
}
catch (final Throwable e)
{
Log.e(Constant.TAG, TAG + "SERVER Error ", e);
}
int errorCount = 0;
int count = 0;
final boolean isRunning = true;
boolean isStoped = false;
try
{
while (!isStoped)
{
try
{
count++;
serverConnection.acceptAndOpen(this);
}
catch (final InterruptedIOException e)
{
isStoped = true;
break;
}
catch (final Throwable e)
{
if (errorCount > 3)
{
isStoped = true;
}
if (isStoped)
{
return;
}
errorCount++;
Log.e(Constant.TAG, TAG + "acceptAndOpen ", e);
continue;
}
errorCount = 0;
}
}
finally
{
Log.d(Constant.TAG, TAG + "OBEX Server finished!");