Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid HTTP POST not working with PARTIAL WAKE LOCK when the phone screen goes dark
    primarykey
    data
    text
    <p>I have a code which has an activity with a button which when clicked starts the accelerometer service . <br/> Accelerometer service Uses <code>PARTIAL_WAKE_LOCK</code> in the <code>onStart()</code> as shown :<br/> <br/></p> <pre><code>@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() </code></pre> <p><br/> and in the onSensorChange(Sensor event) i have the code which logs the data to remote server using HTTP POSt as shown : <br/> <br/></p> <pre><code>synchronized public void onSensorChanged(SensorEvent event) { if( event.sensor.getType() == Sensor.TYPE_ACCELEROMETER ) { //-----------------------------sending it to server--------- ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(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 </code></pre> <blockquote> <p>My problem is : <br/> When the phone screen goes dark ,HTTP stops logging to the server . But when the screen is <br/>bright even if the keypad is locked it logs data . <br/> Please help me as i want to make this service run in background and log data to server even when<br/> the screen is locked . <br/> So , its working fine till the screen goes dark after which its not logging any data .<br/></p> </blockquote> <pre><code>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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload