Zolf
asked on
Android code implementation question
hello there,
i am trying to authenticate user with my remote db.the client uses android device to login.i have implemented the logic.but i have doubt if i am using correct standard.for e.g. from my login activity i am creating instance of ConnectiobImpl to validate user.is it correct or no.i have attached my code.please help.also i want to know about what exception do i need to catch and where.
cheers
zolf
ConnectionImpl.java
Login.java
i am trying to authenticate user with my remote db.the client uses android device to login.i have implemented the logic.but i have doubt if i am using correct standard.for e.g. from my login activity i am creating instance of ConnectiobImpl to validate user.is it correct or no.i have attached my code.please help.also i want to know about what exception do i need to catch and where.
cheers
zolf
ConnectionImpl.java
Login.java
few things:
- you should avoid using networking from the main thread, otherwise on Honeycomb onwards you get the exception (see here)
- HttpClient.execute() throws 2 exceptions, so you should catch them (and Exception as well).
- you could do it in the background AsyncTask
- you should avoid using networking from the main thread, otherwise on Honeycomb onwards you get the exception (see here)
- HttpClient.execute() throws 2 exceptions, so you should catch them (and Exception as well).
- you could do it in the background AsyncTask
ASKER
thanks for your feedbacks.
>>you should avoid using networking from the main thread, otherwise on Honeycomb >>onwards you get the exception
can you please give me an e.g.
>>you could do it in the background AsyncTask
what can i do in the background
>>you should avoid using networking from the main thread, otherwise on Honeycomb >>onwards you get the exception
can you please give me an e.g.
>>you could do it in the background AsyncTask
what can i do in the background
- networking: have you read that link I posted? it says "StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application's main thread responsive, you also prevent ANR dialogs from being shown to users."
So in practice it will throw an exception when you execute your http requests from main thread
- async task: you can inherit from AsyncTask, show ProgressDialog and then dismiss it when you get to onPostExecute()
So in practice it will throw an exception when you execute your http requests from main thread
- async task: you can inherit from AsyncTask, show ProgressDialog and then dismiss it when you get to onPostExecute()
ASKER
can you please with reference to my code.help/guide me to use the things you mentioned about StrictMode
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
ASKER