Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6701339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:55:22+00:00 2026-05-26T06:55:22+00:00

Well I am having a stranger problem here in my android app. I made

  • 0

Well I am having a stranger problem here in my android app.

I made an alarm that starts a service, something like this:

public class ExecutaAcoes extends Service implements Runnable {     
protected static final String URL = "http://www.mysite.com.br"
@Override
public void onCreate() {        
Log.i("Teste","Service started");
    new Thread(this).start();
}
@Override
public void run() {
try {
     Log.i("Teste","Thread started");                       
     HttpClient client = new DefaultHttpClient();
     HttpGet request = new HttpGet(URL);
     HttpResponse response = client.execute(request);
     HttpEntity entity = response.getEntity();
     if (entity != null) {
               ...
    } catch (Throwable e) {
       Log.i("Teste","erro excepty: "+e.toString());
    } finally {

};   

So, every 30 seconds alarm manager starts the service and it accesses the webpage http://www.mysite.com.br. This code works fine in emulator but not on my device. When the phone sleeps (and the screen blackout) the webpage is not accessed and application returns an error in catch (Throwable e): “java.net.UnknownHostException: Host is unresolved” or return a socket error.

The strange thing is that if I press any button on the device and the screen lights up the application returns to work normally and the web site is accessed.
Does anyone know how to solve this problem?

Thanks for some help
Alexandre

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:55:23+00:00Added an answer on May 26, 2026 at 6:55 am

    This is normal. When device goes to sleep some functions are not available. AlarmManager holds a CPU wake lock, so that your onReceive() method gets executed when alarm goes off. Note that this only affects this method: if you start a service this guarantee does not extend to this service. Also, it only gives you CPU wake lock, meaning that CPU will be running, but not the screen and network.

    To access the Wifi from your service you need to acquire the WifiManager.WifiLock. For 3g, screen and other functions see PowerManager.

    Also, running network scan every 30s all the time will drain the battery in a matter of hours – users will not like this. Reconsider using server push (with wifi lock) or sync adapter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, well I'm having a problem and this weird symbol is showing up â€
I am having a strange problem ( well, at least i find it strange
well the thing is i am having a scheduled script that checks some changes
Well, this is my first post here and really enjoying the site. I have
I'm having a strange problem, that I've been trying to solve for too long.
I have been having a small problem that I can't by-pass it, I keep
I am having a strange problem with boolean logic. I must be doing something
I'm having a strange problem here. I'm moving a (working) site to a new
I'm having a problem setting up datanucleus enhancer to use with a google app
I'm having an issue with a Coldfusion component that I'm building. Well, I'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.