0

I am developing an app for SMS gateway. I want to count inbox SMS and compare it to the server where getway is sending the SMS if inbox sms and server SMS is equal then I want to backup my inbox sms and then delete inbox sms. In this app I am able to count,backup and delete the inbox sms, but I dont know how to make an Http request and compare my inbox sms to the server. Plz help me I am a learner. My code is here :

TextView view = new TextView(this);

    Uri uriSMSURI = Uri.parse("content://sms/inbox");
    long now = System.currentTimeMillis();
    long last24 = now - 24*60*60*1000;//24h in millis
    String[] selectionArgs = new String[]{Long.toString(last24)};
    String selection = "date" + ">?";
    String[] projection = new String[]{"date"};
    Cursor cur = getContentResolver().query(uriSMSURI, projection, selection, selectionArgs,null);

    String sms = String.valueOf(cur.getCount());

     view.setText("Total incoming today SMS  "+sms);

    setContentView(view);
NewUser
  • 3,729
  • 10
  • 57
  • 79
Ashfaque
  • 1,254
  • 1
  • 22
  • 38
  • Are you looking for explanations on how to do the whole thing (which would require you to make a web service and send requests to the service) or just how to talk to a web service you've already written? For the first, the question is really too broad. For the second, look at http://stackoverflow.com/questions/3505930/make-an-http-request-with-android – Gabe Sechan Feb 18 '13 at 07:12
  • Thanks @ Gabe Sechan for responding, i am a new learner and i dont know how to make a web service and send requests to the service. Please suggest me thanks in advance – Ashfaque Feb 18 '13 at 07:20
  • That's a lot of work. Basically you need a URL on your webserver that reads parameters in, does whatever you want to do, and then sends the result back to the caller via JSON or XML usually. I can't explain it in a SO comment, they write books on the subject. You're going to need to do some research. – Gabe Sechan Feb 18 '13 at 07:23
  • Thanks again really it was very useful knowledge for me but i am not responsible to do the server side coding. its already have been coded in JSON, i have to do just client side coding please me some suggest me or give me some tutorial/code. Thanks again from my bottom of heart – Ashfaque Feb 18 '13 at 07:30

1 Answers1

0

Ok, so after comments it looks like you just need an HTTP request and make it parse the returning JSON. Take a look here and in the linked articles. Remember that the HTTP request must be done on an AsyncTask or thread.

Community
  • 1
  • 1
Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127