title: Why AlarmManager executes Async Http Request twice?
body: <p>UPDATE:
  I've found my "twice" problem reason. I started "runAlarm()" twice.
  So the code below  works okay.
  It sends  Async HTTP request periodically. 
  You should add to manifest this line:</p>
  
  <pre><code>&lt;receiver  android:process=":remote" android:name="Alarm"&gt;&lt;/receiver&gt;
  </code></pre>
  
  <p>ORIGINAL QUESTION:
  I did HTTP  requests periodically using AlarmManager.
  It works okay in loop.
  But each HTTP request is executed twice.
  I've used some AlarmManager example without understanding what means "bla-bla" there.
  If you ask me why I don't use Timer,
  my answer is that I get error trying to touch Views out of timer thread to show results of HTTP requests.
  My code is below.
  Thanks in advance!.</p>
  
  <pre><code>    private void startHttpRequests() {
           setAlarm();
      }
  
  public void setAlarm()
  {
      BroadcastReceiver receiver = new BroadcastReceiver() {
          @Override public void onReceive( Context context, Intent _ )
          {
              asyncPostRequest();
              context.unregisterReceiver( this ); // this == BroadcastReceiver, not Activity
          }
      };
      this.registerReceiver( receiver, new IntentFilter("com.blah.blah.somemessage") );
      PendingIntent pintent = PendingIntent.getBroadcast( this, 0, new Intent("com.blah.blah.somemessage"), 0 );
      AlarmManager manager = (AlarmManager)(this.getSystemService( Context.ALARM_SERVICE ));
      pollPeriod=1000*10;
      manager.set( AlarmManager.ELAPSED_REALTIME_WAKEUP,
              SystemClock.elapsedRealtime() + pollPeriod, pintent );
  }
  private void asyncPostRequest() {
      new HttpPostDemo().execute("http://www.google.com");
  }
  
  @Override
  protected void onPostExecute(String result)  //HTTP POST result
  {
      printDebug("received="+result);
      setAlarm();
  }
  
  public class HttpPostDemo extends AsyncTask&lt;String, Void, String&gt;
  {
      @Override
      protected String doInBackground(String... urls)
      {
          BufferedReader inBuffer = null;
          String url= urls[0];
          String result = "fail";
          try {
              HttpClient httpClient = new DefaultHttpClient();
              HttpPost request = new HttpPost(url);
              List&lt;NameValuePair&gt; postParameters =
                      new ArrayList&lt;NameValuePair&gt;();
              postParameters.add(new BasicNameValuePair("operanda", "5"));
              postParameters.add(new BasicNameValuePair("operandb", "6"));
              postParameters.add(new BasicNameValuePair("answer", "11"));
              UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(
                      postParameters);
  
              request.setEntity(formEntity);
              HttpResponse httpResponse = httpClient.execute(request);
              inBuffer = new BufferedReader(
                      new InputStreamReader(
                              httpResponse.getEntity().getContent()));
  
              StringBuffer stringBuffer = new StringBuffer("");
              String line = "";
              String newLine = System.getProperty("line.separator");
              while ((line = inBuffer.readLine()) != null) {
                  stringBuffer.append(line + newLine);
              }
              inBuffer.close();
  
              result = stringBuffer.toString();
  
          } catch(Exception e) {
              // Do something about exceptions
              result = e.getMessage();
          } finally {
              if (inBuffer != null) {
                  try {
                      inBuffer.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
          return result;
      }
  </code></pre>