Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

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
Avatar of Zolf
Zolf
Flag of United Arab Emirates image

ASKER

please help
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
Avatar of Zolf

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
- 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()
Avatar of Zolf

ASKER

can you please with reference to my code.help/guide me to use the things you mentioned about StrictMode
ASKER CERTIFIED SOLUTION
Avatar of alexey_gusev
alexey_gusev
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zolf

ASKER

thanks