Android Development crash
<p>I developp an application with Eclipse, I use Android 2.1 API 7, my application interact with an external database (JSON). I haven't any problem when my emulator is turn with Android 2.1, but when I turn my emulator with Android 4.0, my application crash when I would interact with the external database...</p>

<p>Logcat log :</p>

<pre><code>11-18 18:44:56.852: D/dalvikvm(601): Not late-enabling CheckJNI (already on)
11-18 18:44:58.141: D/gralloc_goldfish(601): Emulator without GPU emulation detected.
11-18 18:44:58.301: W/TextLayoutCache(601): computeValuesWithHarfbuzz -- need to force to single run
11-18 18:44:58.301: W/TextLayoutCache(601): computeValuesWithHarfbuzz -- need to force to single run
11-18 18:45:06.601: D/AndroidRuntime(601): Shutting down VM
11-18 18:45:06.601: W/dalvikvm(601): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
11-18 18:45:06.631: E/AndroidRuntime(601): FATAL EXCEPTION: main
11-18 18:45:06.631: E/AndroidRuntime(601): android.os.NetworkOnMainThreadException
11-18 18:45:06.631: E/AndroidRuntime(601):  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1084)
11-18 18:45:06.631: E/AndroidRuntime(601):  at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
11-18 18:45:06.631: E/AndroidRuntime(601):  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
11-18 18:45:06.631: E/AndroidRuntime(601):  at java.net.InetAddress.getAllByName(InetAddress.java:220)
11-18 18:45:06.631: E/AndroidRuntime(601):  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-18 18:45:06.631: E/AndroidRuntime(601):  at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-18 18:45:06.631: E/AndroidRuntime(601):  at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-18 18:45:06.631: E/AndroidRuntime(601):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-18 18:45:06.631: E/AndroidRuntime(601):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
11-18 18:45:06.631: E/AndroidRuntime(601):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-18 18:45:06.631: E/AndroidRuntime(601):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
11-18 18:45:06.631: E/AndroidRuntime(601):  at com.example.library.JSONParser.getJSONFromUrl(JSONParser.java:42)
11-18 18:45:06.631: E/AndroidRuntime(601):  at com.example.library.UserFunctions.loginUser(UserFunctions.java:32)
11-18 18:45:06.631: E/AndroidRuntime(601):  at com.example.lagrandechasse.LoginActivity$1.onClick(LoginActivity.java:54)
11-18 18:45:06.631: E/AndroidRuntime(601):  at android.view.View.performClick(View.java:3480)
11-18 18:45:06.631: E/AndroidRuntime(601):  at android.view.View$PerformClick.run(View.java:13983)
11-18 18:45:06.631: E/AndroidRuntime(601):  at android.os.Handler.handleCallback(Handler.java:605)
11-18 18:45:06.631: E/AndroidRuntime(601):  at android.os.Handler.dispatchMessage(Handler.java:92)
11-18 18:45:06.631: E/AndroidRuntime(601):  at android.os.Looper.loop(Looper.java:137)
11-18 18:45:06.631: E/AndroidRuntime(601):  at android.app.ActivityThread.main(ActivityThread.java:4340)
11-18 18:45:06.631: E/AndroidRuntime(601):  at java.lang.reflect.Method.invokeNative(Native Method)
11-18 18:45:06.631: E/AndroidRuntime(601):  at java.lang.reflect.Method.invoke(Method.java:511)
11-18 18:45:06.631: E/AndroidRuntime(601):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-18 18:45:06.631: E/AndroidRuntime(601):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-18 18:45:06.631: E/AndroidRuntime(601):  at dalvik.system.NativeStart.main(Native Method)
11-18 18:45:08.711: I/Process(601): Sending signal. PID: 601 SIG: 9
</code></pre>

<p>Can you help me ?</p>

<p>Thank for your response, this is my login class :</p>

<pre><code>public class LoginActivity extends Activity {

    //My variable

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);

        //initialize button and textwiew

        btnLogin.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {

                UserFunctions userFunction = new UserFunctions();
                JSONObject json = userFunction.loginUser(login,pass);

                try {
                    if (json.getString(success) != null) {
                        loginErrorMsg.setText("");
                        String res = json.getString(success);
                        if(Integer.parseInt(res) == 1){

                            DatabaseHandler db = new DatabaseHandler(getApplicationContext());
                            JSONObject json_user = json.getJSONObject("user");

                            userFunction.logoutUser(getApplicationContext());
                            db.addUser(json_user.getString(ID), json_user.getString(login));                        

                            Intent dashboard = new Intent(getApplicationContext(), DashboardActivity.class);

                            dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(dashboard);

                            finish();
                        }
                        else{
                            loginErrorMsg.setText("Error");
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
</code></pre>

<p>Can you show me the modification ?
Thanks !</p>
