Sweety Bertilla Sweety Bertilla - 1 year ago 111
Android Question

Android login and forgot password - Actvity or fragment

I am creating a login page which will have forgot password right now:

  1. Login Page is one
    and Forgot Password page is another

  2. Each one calls an
    for http post which returns a

  3. Hence I have callback listener in each `Activity.

  4. In the call back listener I get the
    response, which I parse in separate
    for each Login and separate one for Forgot password

I need to know whether its good practice to do this way or use
. Also any other better way to developing it?

Answer Source

I would suggest using a Fragment per page, so one for "Login" and one for "Forgot Password", and one Activity that handles the async http request. You would then be able to use the fragment methods such as fragment.replace() to swap out the screens without each fragment having to have a callback listener. The activity then can also parse the callback listener once instead of twice in each separate activity. Also, the way Android is heading, Fragments are better to use for UI elements than separate Activities as it makes UI updates quicker and smoother then starting a new activity.

There is an Android Developer API Guide loaders available to every Activity and Fragment. Why not check it out. On that same site you can also find guides to use fragments in your activity.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download