Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Login Form #46

Closed
kukusumaa opened this issue Jul 18, 2014 · 3 comments
Closed

Adding Login Form #46

kukusumaa opened this issue Jul 18, 2014 · 3 comments

Comments

@kukusumaa
Copy link

Hi,
is it possible if i add another json parser for login form?
like the tutorial :
http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

I add the files on com.baker.abaker
but there is an error :

07-17 23:10:14.606 1592-1592/com.cisomagz.ciso E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.cisomagz.ciso, PID: 1592
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at com.baker.abaker.library.JSONParser.getJSONFromUrl(JSONParser.java:51)
at com.baker.abaker.library.UserFunctions.loginUser(UserFunctions.java:48)
at com.baker.abaker.LoginActivity$1.onClick(LoginActivity.java:66)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)

@hsalazarl
Copy link

Hello @QwertyPong,

The problem is that you are trying to make network operations on the same UI thread, Android forbids this, that's why you get that exception.

You need a new thread by creating a class that extends AsyncTask.

Please check: http://developer.android.com/reference/android/os/AsyncTask.html

Best regards.

@hsalazarl
Copy link

Oh, something else, if you want to send POST requests, you can use the class PostClientTask that comes with ABaker. This class already extends the AsyncTask, you just need to pass the needed parameters.

Check how we use it in the function sendDownloadReport() of the MagazineThumb class.

Best regards.

@kukusumaa
Copy link
Author

Great. it works. Thanks @hsalazarl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants