12-10-2009 02:01 AM
i've got such a problem. my apps run in background and starts after device restart. imagine, that the device has been restarted and the user forgot about it and left for about 5min (so after 5min he came back, insert sim-code and unlock the keyboard). after that network is on and device works.
right now, my app waits 60secs after restart and after that starts http requests. but if there is a situation i've described-that user left the device for few min, requests would be failed.
ok, so thought that maybe i'll try checking signal level/radio state/network name etc..
so i wrote simply apps, which for 100sec, every 5secs checks: RadioInfo.getState(), RadioInfo.getSignalLevel(), RadioInfo.getNetworkName(0) and RadioInfo.getCurrentNetworkName().
i've installed my new app, restarted the device but i wait few minutes before putting pin and start running the device. so-the device was after restart but it was waiting for the pin. the sign of radio was red, there was no network name. so in this situation no http requests could be done.
i thought that for this time, RadioState would give me that Radio is off, that the signal level would be 'no coverage' and that there would be no network name.. i was wrong. i've checked in logs (which were written every 5secs) and after about 20-30secs, radio went to On, there was coverage and there was network name-but another carrier! (i mean, not the carrier which sim card was inside)!
can anyone explain me this situation? device was waiting for pin, network-icon was red, no network name, no http request can be done right now, but the device said that the radio is on, there is coverage and there is another's carrier network (it all started aftr about 30secs, before that radio was off, no coverage, no network name).
and also-how can i detect if http requests can now be done?
regards and thx for replies
12-10-2009 04:08 AM
even without a sim card you can do emergency calls. the phone registers with the phone network but does not offer all capabilities. when you enter the sim code the phone connects to the provider of the sim card and is authorized.
i would suggest to use the CoverageInfo class to check for available data network, it provides much simpler access.
instead of checking after 60s i would suggest to register a coveragechangelistener, run the connection if it fires a coverage change.