Is there a way to send sms from android mobile to server?

I have an Android app in my mobile device where I fill in some data and then I want to add that data to the database. So I am planning to add a button (sms button) to my application, by clicking this button, the data should be updated to the server database or just dump the data on the server. So I want to know if we can send sms to the server? And if so, how?
Note. I have a server with a static IP address.


source to share

3 answers

try sending data to server.

public void postData() {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("");

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("id", "msgId"));
        nameValuePairs.add(new BasicNameValuePair("stringdata", "Msg u want send"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request

        HttpResponse response = httpclient.execute(httppost);
        Log.v("myapp", "response " + response.getEntity());
        String responseBody = EntityUtils.toString(response.getEntity());

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
    } catch (IOException e) {
        // TODO Auto-generated catch block


You can refer to Android HttpPost: how to get the result



You can try with an HTTP request and have a serveride script (php / java / ...) collect the data and put it in the database. Encoding can be done with JSON (or one of its variants). The fact that you have a static IP address makes this pretty easy.

If you have dataconnection (and since you are using a smartphone, you probably do), you are better off using your internet connection.



When you add a GPRS modem to your server and insert an active SIM card into it, you can send SMS messages to that number, and then you still need a service that will read your SMS messages and convert / dump data to the server itself.



All Articles