I have a connection running in a thread that sends data back via a http connection. When the battery is in critical and radio is turned off, the connection is lost. This issue has been
discussed before.
The thread contains the http connection as follows:
Code:
StreamConnection connection = (StreamConnection)Connector.open(rawUrl);
HttpConnection httpConn = (HttpConnection)connection;
The problem of auto-establishing the connection again seems to be more difficult than I first thought. I assumed I could just stop the thread gracefully (does this remove the instance of the thread? I assume so).
Code:
if (stop){
return;
}
This all goes fine in the simulator, the thread stop and then re-starts (due to a programatic check on battery & when data needs to be sent).
Code:
if (sendThread != null)
{
if (!sendThread.isAlive())
{
sendThread = new SendThread(url);
sendThread.start();
}
}
else
{
sendThread = new SendThread(url);
sendThread.start();
}
However, because radio is also switched off when in critical battery, and NOT automatically turned back on when it returns to 'good', the connection never takes place.
So my question is, how would you programattically check and re-establish GPRS/http connection. Would it be via the Radio class in the BB API? Do you think this will resolve the issue?
I was thinking something like:
Code:
if (GPRSInfo.getGPRSState() == GPRSInfo.GPRS_STATE_IDLE)
{
Radio.activateWAFs(someIntegerHere);
}
Anyone else come across and solved this?