I wrote an app that use Alarm manager to execute a service (that hold a wakelock to perform the entire execution) every minutes to upload data on net, and it works perfect....sometimes.
Infact using Logcat (on phone) i saw that sometimes the WiFi connection doesn't work. The icon on the status bar it's ok, and i had set "never" for wifi standby.
Sometimes the app is running ok for more than 20 hours, some other times just 40 minutes and then wifi seems to be down (but there is still icon and configuration rigth set).
Doing a last test i tried to open the browser and it doesn't work too! Torestart the upload i need to disable and enable wifi...So i think that the problem is in android.
My device is Samsung Galaxy ACE with Android 2.2
I have solved only doing a disable and enable connection bettween the operation.
//disable connection
android.provider.Settings.System.putInt(getContentResolver(),android.provider.Settings.System.AIRPLANE_MODE_ON,1);
// Post an intent to reload
Intent intent1 = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent1.putExtra("state", 1);
sendBroadcast(intent1);
//connection disabled
//enable connection
android.provider.Settings.System.putInt(getContentResolver(),android.provider.Settings.System.AIRPLANE_MODE_ON,0);
// Post an intent to reload
Intent intent4 = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent4.putExtra("state", 0);
sendBroadcast(intent4);
//Connection enabled