Android Question HttpServer and phone can't sleep ! [solved]

Discussion in 'Android Questions' started by robotop, Jul 6, 2015.

  1. robotop

    robotop Member Licensed User

    Hi all, I used the HttpServer library for a small project. For my purposes the server isn't used as a service, but as activity, so it is started on ActivityCreate and stopped on ActivityPause. I tested the application on 3 different smartphones:
    a) MID-A13 with Android 4.2.2
    b) E1000 with Android 2.2.1
    c) Galaxy Nexus with Android 4.3
    For models a) and b) there are no problems, but the model c) has a problem: after installing the application, the phone can' be set to sleep (I know, the HttpServer is exciting). If you try to suspend with the button, it goes "off" (display off) then resumes "on" after a variable time, one to ten seconds. This makes the phone unuseable and I don't want to distribute an application with this problem. The normal status, also, is impossible to recover. I tried:
    a) close the App with the application manager
    b) uninstall the App
    c) completely turn OFF the phone, also removing the battery for a couple of minutes.
    All such operations had no effect. When turning ON the phone again, the old behaviour was restored: the phone can't be turned off.
    Initially, I thinked about an hardware problem. The phone is damaged. I tried to restore the default phone conditions, erasing all my data and preferences :( and in such case the phone revived, perfectly working. Reinstalling the App with the HttpServer reintroduced the problem. Please, note that if the phone is connected to a PC with usb cable the problem does not exists, it can be suspended regularly and doesn't resumes automatically. I don't know why this happens only on the Samsung phone.
    Has anyone faced a similar problem ? Thank you.
    Last edited: Jul 6, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    I never encountered such issue.

    HttpServer doesn't do anything special. Are you using PhoneWakeState in your app?
  3. robotop

    robotop Member Licensed User

    Hi Erel. Thank you for your prompt answer. In the first version I used the PhoneWakeState to maintain ON the activity for an indefinite time (the normal state was restored at exit button click). After the error described here, I removed the PW, but the behaviour was exactly the same. The very strange thing is that the problem still remains even uninstalling the application !
  4. robotop

    robotop Member Licensed User

    Well, after some additional tests, the problem exists even if the HttpServer is not used. The phone can't go to sleep. It goes in suspend / sleep only if connected to PC or to a Wall-adapter with the standard USB cable. So, the problem does not belongs to the HttpServer. The phone works fine after a reset to the default configuration, then there must be some App that I install after the reset or one Update that creates the problem. I will indagate further more to find what's the reason for this strange behaviour.
  5. robotop

    robotop Member Licensed User

    Ok, it's an hardware problem. After resetting the phone to initial conditions, the problem is still present. There must be a fault related with battery level or with the USB plug detection; also the on/off button seems to have unusual contact bounces, 'cause just knocking the phone's border it's enough to turn on the device when in sleep condition. I'm afraid it's time to buy a new phone. Sorry for thinking it was a software problem...
    Last edited: Jul 7, 2015
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice