-2

I am doing the tutorial in this link but im going circle for hours in one error i tried all the things they say but its not working for me...i might find someone here who has idea...i followed all he says one thing i dont understand is where he got these files. i think im having a problem with url he didnt mention where to put or get these files.

private static String loginURL = "http://10.0.2.2/ah_login_api/";
    private static String registerURL = "http://10.0.2.2/ah_login_api/";

this is my errorerror

Giant
  • 1,619
  • 7
  • 33
  • 67
  • possible duplicate of [android.os.NetworkOnMainThreadException](http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception) – laalto Apr 26 '14 at 06:00
  • @laalto i dont think its a duplicate since he has a specific problem while im just guessing and asking for suggestions on how to fix my problem – Giant Apr 26 '14 at 06:03
  • 1
    The trace you posted has `NetworkOnMainThreadException` on top and the linked duplicate has specific instructions to fix it (`AsyncTask` being the canonical solution). Possibly after fixing that you have your next problem, but that's the first step for now. – laalto Apr 26 '14 at 06:08

1 Answers1

0

The reason is because you didn't use Async Task to carry out the network process. Please use Async task to make sure your app runs without error. Still if you don't want to use Async task, please add the following code

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy); 

This solution just hides your problem.

Behavious may be expected.

Its better to go with async task

Make sure you have given permission in Manifest.

<uses-permission android:name="android.permission.INTERNET"/>
Mohammed Imran N
  • 1,279
  • 1
  • 11
  • 26
  • i dont know about async task thing im a new programmer and learning for tutorials i have the permission you put there and async task is not included in his tutorial so i didnt put it in my code... – Giant Apr 26 '14 at 06:01
  • check this example and proceed. http://www.androidhive.info/2012/10/android-multilevel-listview-tutorial/ – Mohammed Imran N Apr 26 '14 at 06:06