Issue
I want to distinguish the following use cases:
Case 1: A user stays within the same app and navigates through different activities of the same app.
Case 2: A user navigates out of the app, might just call the home screen of his device or call an activity from some other app.
In Case number 2 I want to refresh some data when my main activity is called again, where in case number 1 that is not necessary. The lifecycle methods onResume() and onStart() are called in both cases, so simply placing my code there is not possible. What can I do? Thanks.
Solution
You'll have to write to a shared preference whenever you issue a navigation command that would take you out of your app and check that shared preference when your main Activity is loaded. To handle the back button case you can override onBackPressed()
in your activities and to handle pressing of the home button you can check this blog post: http://nisha113a5.blogspot.com/. If you want to handle the recent apps switcher you can do something similar to the home button method.
Answered By - dcow
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.