I got a Fatal EXCEPTION: main.
I believe that my exception is caused by the following code:
    public void onClick(View view) {
        String name = inputName.getText().toString();
        String password = inputPassword.getText().toString();
        UserFunctions userFunction = new UserFunctions();
        Log.d("Button", "Login");
            SONObject json = userFunction.loginUser(name, password);
        // check for login response
        try {
            if (json.getString(KEY_SUCCESS) != null) {
                loginErrorMsg.setText("");
                String res = json.getString(KEY_SUCCESS); 
        ....code body
And here is my Logcat
08-20 18:41:26.490: E/AndroidRuntime(4240): FATAL EXCEPTION: main
08-20 18:41:26.490: E/AndroidRuntime(4240): android.os.NetworkOnMainThreadException
08-20 18:41:26.490: E/AndroidRuntime(4240):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
08-20 18:41:26.490: E/AndroidRuntime(4240):     at   libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
08-20 18:41:26.490: E/AndroidRuntime(4240):     at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
When I change the code to following, I got no Exception.
Log.d("Button", "Login");
//JSONObject json = userFunction.loginUser(name, password);
try {
        if (json.getString(KEY_SUCCESS) != null) {
        loginErrorMsg.setText("");
        String res = json.getString(KEY_SUCCESS);
code body.....
Any help?
Thanks.
 
     
    