[android-developers] Re: How to intercept when the application is brought to foregroud from background

2011-02-11 Thread mah
If your intention is to call another activity in order to perform some
work -- do you control that activity? Start it for result rather
than simply starting it. That way you'll get a callback (with its
result) when it finishes.

I agree with Mark, you should not care about what activities outside
of your control do. You should code as if they don't exist, and if
there's some reason to consider the user logged out, it should not
be based on what activity is current. Is there some use case you can
think of that justifies taking special action just because the user,
for example, opened their messaging app to reply to the message they
just received?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to intercept when the application is brought to foregroud from background

2011-02-11 Thread Kostya Vasilyev

My two cents as an imagined user of this application:

Do not log me out just because your activity was deactivated.

If I'm using your application and want to respond to an incoming phone 
call, or another event (such as an SMS or a new email notification) - 
when done with that quick interruption, I want to come back to your 
application and continue with whatever I was doing.


Requiring me to log in again, even though I was away for a short time, 
would seriously interrupt the flow of interacting with the phone.


Rather, implement a scheme where sessions are time limited.

This of course assumes that the application does not contain 
security-sensitive data, then it's different (but I don't see you saying 
it is).


-- Kostya

11.02.2011 15:12, mah пишет:

If your intention is to call another activity in order to perform some
work -- do you control that activity? Start it for result rather
than simply starting it. That way you'll get a callback (with its
result) when it finishes.

I agree with Mark, you should not care about what activities outside
of your control do. You should code as if they don't exist, and if
there's some reason to consider the user logged out, it should not
be based on what activity is current. Is there some use case you can
think of that justifies taking special action just because the user,
for example, opened their messaging app to reply to the message they
just received?




--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to intercept when the application is brought to foregroud from background

2011-02-10 Thread Hari
Hi Mark,
Thanks for validating our approach.

If you are called with onResume() and not onCreate(), you are coming
back onto the screen after having not been on the screen.

There are 2 possibilities,
1. you come back to the same screen (activity) due to the application
flow. Navigate to other activities and come back to it due to
application functionality.
2. you come back after you navigate away to another application.

Is there a way to recognize this using the application attributes or
context attributes.

Regards
Hari

On Feb 10, 2:24 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Thu, Feb 10, 2011 at 2:19 PM, Hari mba.for.d...@gmail.com wrote:
  Out Mobile Application required the user to provide username and
  password to login.

 Why?

  After login, if the user navigates to another
  application and tries to come back to our application again, i would
  like to intercept this action and redirect the user to login screen
  and then lead to where ever he was before.

  How can i achieve this?

 onResume()

  Currently we are doing it a very crude way by tracking the user's
  action in variables and in onResume() we check for the value of the
  variable and make a decision if he should continue or be redirected to
  login.

 Sounds about right.

  Is there something to the order of an Interceptor which can use tell
  me if the application coming to foreground was actually in the
  background and not a new process.

 If you are called with onResume() and not onCreate(), you are coming
 back onto the screen after having not been on the screen.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android App Developer Books:http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to intercept when the application is brought to foregroud from background

2011-02-10 Thread Mark Murphy
On Thu, Feb 10, 2011 at 4:53 PM, Hari mba.for.d...@gmail.com wrote:
 There are 2 possibilities,
 1. you come back to the same screen (activity) due to the application
 flow. Navigate to other activities and come back to it due to
 application functionality.
 2. you come back after you navigate away to another application.

 Is there a way to recognize this using the application attributes or
 context attributes.

Your app should not care one way or another. The user is logged in, or
the user is not logged in. It does not matter whether the previous
activity was one of yours or not one of yours.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to intercept when the application is brought to foregroud from background

2011-02-10 Thread Kevin Duffey
There are probably a few other ways to do this. If the user goes away from
your app, and android doesn't shut it down, then comes back, the user should
still be logged in right? As Mark said, onResume() is where you can figure
this out.

Another way is to use SQLite or something to store a session token and in
onResume look it up and check the timestamp of when it was stored (you'd put
that in your onPause..storing it with timestamp). Then, if the timestamp is
 some amount of time, continue with it.. if not, invalidate and take to
login screen. Any form of storage could be used for this.. since a phone is
a single user device, you could store a file like a lock file, etc.


On Thu, Feb 10, 2011 at 1:56 PM, Mark Murphy mmur...@commonsware.comwrote:

 On Thu, Feb 10, 2011 at 4:53 PM, Hari mba.for.d...@gmail.com wrote:
  There are 2 possibilities,
  1. you come back to the same screen (activity) due to the application
  flow. Navigate to other activities and come back to it due to
  application functionality.
  2. you come back after you navigate away to another application.
 
  Is there a way to recognize this using the application attributes or
  context attributes.

 Your app should not care one way or another. The user is logged in, or
 the user is not logged in. It does not matter whether the previous
 activity was one of yours or not one of yours.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://github.com/commonsguy
 http://commonsware.com/blog | http://twitter.com/commonsguy

 Android App Developer Books: http://commonsware.com/books

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en