title: How to put in webservice with alarm manager in Android
body: <p>I don't have any idea on how i will put data from webservice and at the same time it will work in alarm manager to send data every set of time. I know how to put data from webservice but with alarm manager I don't have any idea. I try the process of putting data from webservice but it takes an error because the class has extends BroadcastReceiver. This is how i put in the webservice.</p>
  
  <pre><code>public void passdata(View View){
  String a = name.getText().toString();
  RequestParams params = new RequestParams();
  
  if(a != null){
  params.put("name", a);
  WebService(params);
  }
  }
  
  public void WebService(RequestParams params) {
          progressDialog.show();
  
          AsyncHttpClient client = new AsyncHttpClient();
          client.get("http://192.168.8.100:8080/taxisafe3/webService/login", params, new AsyncHttpResponseHandler() {
              public void onSuccess(String response) {
                  progressDialog.hide();
                  try {
                      JSONObject object = new JSONObject(response);
  
                      if (object.getBoolean("status")) {
                          Toast.makeText(getApplicationContext(), "Login Successful!", Toast.LENGTH_LONG).show();
                          finish();
                          gotoHome();
                      } else {
                          Toast.makeText(getApplicationContext(), "Username or Password is incorrect!", Toast.LENGTH_LONG).show();
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
  
              public void onFailure(int statusCode, Throwable error, String content) {
                  progressDialog.hide();
  
                  if (statusCode == 404) {
                      Toast.makeText(getApplicationContext(), "Requested resource not found", Toast.LENGTH_LONG).show();
                  } else if (statusCode == 500) {
                      Toast.makeText(getApplicationContext(), "Something went wrong", Toast.LENGTH_LONG).show();
                  } else {
                      Toast.makeText(getApplicationContext(), "Unexpected Error Occured! (No Internet Connection)", Toast.LENGTH_LONG).show();
                  }
              }
          });
      }
  </code></pre>
  
  <p>How can i do this putting of data in webservice with alarm manager? So that I can send data from the WebService every minute for example. Please help.</p>
  
  <p>UPDATED from Joseph Answer:</p>
  
  <pre><code>    public class Web extends IntentService {
      String msg = "aw";
      public Web(String name) {
          super(name);
      }
  
      @Override
      protected void onHandleIntent(Intent intent) {
          RequestParams params = new RequestParams();
          params.put("message", msg);
          WebService(params);
  
          Intent in = new Intent(Web.this, AlarmReceiver.class);
          PendingIntent pendingIntent = PendingIntent.getBroadcast(Web.this, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
  
          AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
          Calendar calendar = Calendar.getInstance();
          calendar.setTimeInMillis(System.currentTimeMillis());
          calendar.add(calendar.MILLISECOND, 1);
          alarmManager.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(), 1000 * 60 * 1, pendingIntent);
      }
      public void WebService(RequestParams params) {
  
          AsyncHttpClient client = new AsyncHttpClient();
          client.get("http://192.168.254.105:8080/taxisafe3/webService/emergency", params, new AsyncHttpResponseHandler() {
              public void onSuccess(String response) {
                  try {
                      JSONObject object = new JSONObject(response);
  
                      if (object.getBoolean("status")) {
                          Toast.makeText(getApplicationContext(), "Emergency Sent to Server", Toast.LENGTH_LONG).show();
                      } else {
                          Toast.makeText(getApplicationContext(), "Emergency not Sent to Server", Toast.LENGTH_LONG).show();
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
  
              public void onFailure(int statusCode, Throwable error, String content) {
  
                  if (statusCode == 404) {
                      Toast.makeText(getApplicationContext(), "Requested resource not found", Toast.LENGTH_LONG).show();
                  } else if (statusCode == 500) {
                      Toast.makeText(getApplicationContext(), "Something went wrong", Toast.LENGTH_LONG).show();
                  } else {
                      Toast.makeText(getApplicationContext(), "Unexpected Error Occured! (No Internet Connection)", Toast.LENGTH_LONG).show();
                  }
              }
          });
      }
  }
  </code></pre>
  
  <p>Receiver Class</p>
  
  <pre><code>public class AlarmReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent)
      {        
          Intent i = new Intent(context, Web.class);
          context.startService(i);
  }
  }
  </code></pre>