Como gestiona Login Activity...una vez logado

57 views
Skip to first unread message

joaquindiez

unread,
Nov 13, 2011, 3:23:23 PM11/13/11
to AndroidStartup
Hola me estoy armando un poco de lio con la creacion de los
activities...

Tengo un Activity: Init que muestra una imagen de entrada y
dependiendo de si tengo los datos del usuario, muestra la
AplicationActivity o por el contrario abre LoginActivity.


Una vez el usuario mete los datos se almacena la informacion en un
fichero y se abren AplicationActivity.

El problema es que cuando da al boton de Back vuelve a LoginActivity.
y desearia que fuera a la Pantalla de Init...o como mal menor.. salga
de la aplicacion..


Segun habia leido, la forma de abrir la AplicationActivity seria

Intent tabhostAct = new Intent(context, AplicationActivity.class);
tabhostAct.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(tabhostAct);

¿Que estoy haciendo mal?

jlmo...@gmail.com

unread,
Nov 13, 2011, 3:29:36 PM11/13/11
to android...@googlegroups.com
si tu flujo de activities es 

init -> login -> application 

o init -> application si ya tienes los datos de login.

Si haces un start activity de "application" con el FLAG_ACTIVITY_CLEAR_TOP  te abrirá esa actividad cerrando todas las actividades que hayas abierto DESPUES de esa; el flag FLAG_ACTIVITY_NEW_TASK no lo he usado nunca.

Saludos.

2011/11/13 joaquindiez <joaqu...@gmail.com>

Saul Diaz

unread,
Nov 13, 2011, 3:33:19 PM11/13/11
to android...@googlegroups.com
Buenas Joaquín:

Interesante problema.

Yo probaría a añadirle en el AndroidManifest.xml a la <activity> la opción "android:clearTaskOnLaunch = true" a tu ApplicationActivity. Si no lo he entendido mal, es lo que creo que te indica el Android Reference. 

android:clearTaskOnLaunch
Suppose, for example, that someone launches activity P from the home screen, and from there goes to activity Q. The user next presses HOME, and then returns to activity P. Normally, the user would see activity Q, since that is what they were last doing in P's task. However, if P set this flag to "true", all of the activities on top of it (Q in this case) were removed when the user pressed HOME and the task went to the background. So the user sees only P when returning to the task.

Para mas detalle revisa la información en Activities -> Tasks and Back Stack en la Dev Guide.

Atentamente
Saúl Díaz González

joaquindiez

unread,
Nov 16, 2011, 9:04:07 AM11/16/11
to AndroidStartup
Perfecto!! con vuestras aportaciones finalmente lo he
conseguido..gracias!!!!

On Nov 13, 9:33 pm, Saul Diaz <seff...@gmail.com> wrote:
> Buenas Joaquín:
>
> Interesante problema.
>
> Yo probaría a añadirle en el AndroidManifest.xml a la <activity> la opción
> "android:clearTaskOnLaunch = true" a tu ApplicationActivity. Si no lo he
> entendido mal, es lo que creo que te indica el Android Reference.
>
> android:clearTaskOnLaunch
>
> > Suppose, for example, that someone launches activity P from the home
> > screen, and from there goes to activity Q. The user next presses HOME, and
> > then returns to activity P. Normally, the user would see activity Q, since
> > that is what they were last doing in P's task. However, if P set this flag
> > to "true", all of the activities on top of it (Q in this case) were
> > removed when the user pressed HOME and the task went to the background. So
> > the user sees only P when returning to the task.
>
> Para mas detalle revisa la información en Activities -> Tasks and Back
> Stack en la Dev Guide.
>
> Atentamente
> Saúl Díaz González
>
Reply all
Reply to author
Forward
0 new messages