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 9039081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:38:59+00:00 2026-06-16T09:38:59+00:00

I have a code which has an activity with a button which when clicked

  • 0

I have a code which has an activity with a button which when clicked starts the accelerometer service .
Accelerometer service Uses PARTIAL_WAKE_LOCK in the onStart() as shown :

@Override
public void onStart(Intent intent, int startId) {
 // TODO Auto-generated method stub

 super.onStart(intent, startId);

//Power Manager
PowerManager pm = (PowerManager)getApplicationContext().getSystemService(Context.POWER_SERVICE);

 PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MY WK");

 wl.acquire();
 //Power Manager

 try{
mInitialized = false;
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);  
mSensorManager.registerListener(this, mAccelerometer,SensorManager.SENSOR_DELAY_NORMAL);
} 
catch(Exception e)
 { 
  Log.e("acc","catch1");
  }
}// end of onStart()

and in the onSensorChange(Sensor event) i have the code which logs the data to remote server using HTTP POSt as shown :

synchronized public void onSensorChanged(SensorEvent event) {

          if( event.sensor.getType() == Sensor.TYPE_ACCELEROMETER )
           {

             //-----------------------------sending it to server---------

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                nameValuePairs.add(new BasicNameValuePair("xaxis", xaxis));
                nameValuePairs.add(new BasicNameValuePair("yaxis", yaxis));
                nameValuePairs.add(new BasicNameValuePair("zaxis", zaxis));

           //------------------

    Thread networkThread = new Thread() {
    @Override
       public void run() {

    HttpClient httpclient1 = new DefaultHttpClient();
    HttpPost httppost1 = new HttpPost("http://www.xxxxx.com/filename.php");

       httppost1.setEntity(new UrlEncodedFormEntity(nameValuePairs));
       HttpResponse response1 = httpclient1.execute(httppost1);

    }
    };

    networkThread.start();
    //----------------------------------

  }//and of if

 }//end of onSensorChanged

My problem is :
When the phone screen goes dark ,HTTP stops logging to the server . But when the screen is
bright even if the keypad is locked it logs data .
Please help me as i want to make this service run in background and log data to server even when
the screen is locked .
So , its working fine till the screen goes dark after which its not logging any data .

Does HTTP not work with Partial_WAKE_Lock.

I searched for the answers but could not find any. Hoping to get some help ! 

Thank You 
  • 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-06-16T09:39:01+00:00Added an answer on June 16, 2026 at 9:39 am

    Fortunately , i have found an answer in this link Android accelerometer not working when screen is turned off which says that its not the HTTP post not working but when the screen is off no accelerometer values are generated . Thank you

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

Sidebar

Related Questions

I have a launching Activity A1 which has a start button which starts a
I have a home activity ActivityA, which has button that creates an intent, sets
I have an Activity which has an 'OK' button. And I have an 'Edit'
I have code which has a drop down list. And when a certain option
I have a C++ code which has 3 array declarations. float A[NUM]; float B[NUM];
I have some code which I think has extra release statements. Is the code
Imagine you have class A which has code which runs as method M. And
I have a C code in which I have a structure declaration which has
I have code which performs query on Jboss server. It has JNDI based datasource
I have a large library of code which has a few (much too few)

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.