Building first Android App, trying to connect to a URL on load and fetch data
<p>I am trying to learn how to program using Android, and I am trying to make a WEB API call from within the base app that the SDK starts with. I simply copied some code, but I do not detect any connection occuring on my web server. Any ideas?</p>

<pre><code>package com.example.androidhello;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

URL url;{
    try {
        url = new URL("http://192.168.1.15/insertrecord.php");

        HttpURLConnection urlConnection = (HttpURLConnection) url
            .openConnection();

        InputStream in = urlConnection.getInputStream();

        InputStreamReader isw = new InputStreamReader(in);

        int data = isw.read();
        while (data != -1) {
            char current = (char) data;
            data = isw.read();
            System.out.print(current);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    }
}
</code></pre>

<p>When I connect from the browser to the URL, my web server enters a record into mysql so I know the URL was visited, and I echo out a return. the next thing I want to do is store the return and later JSON it, but for now I do not see a call. Any help?</p>

<p>Thanks!</p>
