tag:blogger.com,1999:blog-4023775337223455601.post714153957487064358..comments2024-02-17T15:03:14.887+05:30Comments on Vardhan Blog - My Experiences: Android: Solution to detect when an Android app goes to the background and come back to the foreground without getRunningTasks or getRunningAppProcessesVardhan DShttp://www.blogger.com/profile/06902854396009389430noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-4023775337223455601.post-86007843371153560482020-05-29T18:19:58.651+05:302020-05-29T18:19:58.651+05:30The next time I read a blog, I hope that it doesn’...The next time I read a blog, I hope that it doesn’t disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you weren’t too busy looking for attention. Spot on with this write-up, I truly think this website needs much more consideration. I’ll probably be again to read much more, thanks for that info.<br /><a href="https://vitolker.dk/" rel="nofollow">oversættelsestjeneste</a>Alisahttps://www.blogger.com/profile/00196152607300772760noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-86542824459021855982017-11-19T00:06:47.115+05:302017-11-19T00:06:47.115+05:30May I use the code in my project?May I use the code in my project?Youssef Diranihttps://www.blogger.com/profile/15647750536733944152noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-22271761019350858152017-07-15T15:58:29.580+05:302017-07-15T15:58:29.580+05:30great work its working very awsome .great work its working very awsome .Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-14076525093513542662016-02-11T22:25:17.609+05:302016-02-11T22:25:17.609+05:30I don't feel like you can rely on the absolute...I don't feel like you can rely on the absoluteness of this answer. This will only work if the system calls onWindowFocusChanged before calling onStop. However the documentation makes it clear that onWindowFocusChanged is independent of the Activity lifecycle:<br /><br />"Note that this provides information about global focus state, which is managed independently of activity lifecycles." <br /><br />http://developer.android.com/reference/android/app/Activity.html#onWindowFocusChanged(boolean)<br /><br />Additionally, setting up menu items in your abstract base activity isn't the best idea. All Activities will be required to have those menu items (you may not want a home menu item on your Main Activity).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-2281644949449125412016-01-12T18:14:35.566+05:302016-01-12T18:14:35.566+05:30Why onBackPressed() is used?Why onBackPressed() is used?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-16985501826471872592015-05-22T08:29:58.943+05:302015-05-22T08:29:58.943+05:30I found an issue, please follow the steps to recre...I found an issue, please follow the steps to recreate it.<br /><br />1. Open any app in the device.<br />2. Press "Home" button to minimize the app and then open your own app. (Toast shows up)<br />3. Press "Menu" button, the one which shows thumbnail of you running apps and allow you to switch apps.<br />4. Go to any other app. (Toast not show up) <-- should show up<br />5. Press "Home" button<br />6. Go back to your own app (Toast not show up) <-- should show upAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-74512753902576906152015-04-15T21:01:15.347+05:302015-04-15T21:01:15.347+05:30We can implement the feature by using PowerManager...We can implement the feature by using PowerManager.Vardhan DShttps://www.blogger.com/profile/06902854396009389430noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-28211332065019931512015-04-15T20:59:21.785+05:302015-04-15T20:59:21.785+05:30If process is killed then app is killed too. So, w...If process is killed then app is killed too. So, we can't show the toast message.Vardhan DShttps://www.blogger.com/profile/06902854396009389430noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-21913100356709272015-04-15T11:50:23.436+05:302015-04-15T11:50:23.436+05:30I also want to get notified or show toast when app...I also want to get notified or show toast when app process is killed. How can I achieve it? Is it even possible?nitesh khatrihttps://www.blogger.com/profile/14880992945584893529noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-68877870470344879242015-04-15T11:44:40.223+05:302015-04-15T11:44:40.223+05:30I also want to show the correct toast on screen lo...I also want to show the correct toast on screen lock using power button. How can I implement it?nitesh khatrihttps://www.blogger.com/profile/14880992945584893529noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-78184430036514010042014-11-18T20:14:30.253+05:302014-11-18T20:14:30.253+05:30Thank you for sharing Vhardan, this post helped me...Thank you for sharing Vhardan, this post helped me a lot of to create my app.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-21222094194633906282014-11-14T16:26:06.094+05:302014-11-14T16:26:06.094+05:30Fit perfect for my project! Thank you for sharing!...Fit perfect for my project! Thank you for sharing! Anonymoushttps://www.blogger.com/profile/03686809057859301338noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-65265994633096444082014-10-01T10:41:56.811+05:302014-10-01T10:41:56.811+05:30You can have mTimeStamp variable in applicationdid...You can have mTimeStamp variable in applicationdidenterbackground right. If you want to know when ur application went to background?Anonymoushttps://www.blogger.com/profile/11691190078991338208noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-45228026475258043182014-10-01T02:18:31.963+05:302014-10-01T02:18:31.963+05:30Hi, I am using your logic here for checking if my ...Hi, I am using your logic here for checking if my application has gone to backgound but I am facing some issues.<br /><br />1. Here the API "onWindowFocusChanged(boolean hasFocus)" has been used to check if the BaseActivity (all app activities are derived from here) has focus or not.<br /><br />2. However, this function is called twice during each transition from Activity A to Activity B; once when hasFocus = false, and once when hasFocus = true.<br /><br />3. Hence it is trying to reset mTimesStamp each time and Activity is transitioned.<br /><br />I would like to manipulate the APIs "onWindowFocusChanged" and "onStop" of BaseActivity,to only reset "mTimeStamp" when app goes to background. In rest of the cases, it should pass.<br /><br />Please let me know if this approach can be used to attain my objectiveRia Bhattacharyahttps://www.blogger.com/profile/10198342762544307590noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-9415237343630085112014-06-19T02:21:52.276+05:302014-06-19T02:21:52.276+05:30What i can say is only simple and awesome.. What i can say is only simple and awesome.. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-33098319268833824672014-05-22T15:07:49.755+05:302014-05-22T15:07:49.755+05:30Hi there,
I just wanted to say that this post wa...Hi there, <br /><br />I just wanted to say that this post was helpful. Thank you! That's all :)<br /><br />Regards<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-4037387014647795352014-02-25T14:35:43.943+05:302014-02-25T14:35:43.943+05:30Hi karthik,
Thanks for the comment.
By using Acti...Hi karthik,<br /><br />Thanks for the comment.<br />By using ActivityLifeCycleCallbacks, we can get all the life cycles of activity @ one place but not the status of the app whether it went to background or foreground but we can use this callbacks and also can trigger the solution for app status.<br /><br />Regards<br />Harsha<br />Vardhan DShttps://www.blogger.com/profile/06902854396009389430noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-21638498648611902222014-02-22T16:55:46.201+05:302014-02-22T16:55:46.201+05:30I think you can use ActivityLifeCycleCallbacks (IC...I think you can use ActivityLifeCycleCallbacks (ICS onwards) to do this better.<br />http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.htmlKarthik Ramgopalhttps://www.blogger.com/profile/06444914034546583414noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-81467949416699933532014-02-13T12:55:40.992+05:302014-02-13T12:55:40.992+05:30Hi Arvind,
Thanks for the response.
I have two i...Hi Arvind,<br /><br />Thanks for the response.<br /><br />I have two ideas to implement this scenario (I haven't implemented both)<br /><br />1. You can use a logic to detect and handle whether your in foreground or background in application class, So that no need of using base activity. (This can be achieved)<br /><br />2. ComponentCallbacks2 interface may help by checking onTrimMemory. ( I haven't tried this solution)<br /><br /><br />Vardhan DShttps://www.blogger.com/profile/06902854396009389430noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-57679033336833473282014-02-12T20:48:30.630+05:302014-02-12T20:48:30.630+05:30Hi Vardhan,
I have to do capture Applaunch and Ap...Hi Vardhan,<br /><br />I have to do capture Applaunch and App minimize events for myapp for Appirater integration.<br /><br /> Your code suits good. But i have a problem, i have many activities,fragments in Application.say some Activities extends FragmentActivity, activity and fragments. i have to show the appirater dialog after every 3rd launch of the app, No matter where he is present(fragment/activity/fragmentactivity) <br /><br />.How to handle this case. Because, it needs the architecture changes, if i need to extends all the activities by Base Activity suggested by you. Please help, how can i acheive this.<br /><br /><br />Regards,<br /><br />Arvind AnandalaAnonymoushttps://www.blogger.com/profile/05605575366879727064noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-34817187891882440322014-01-15T10:23:31.955+05:302014-01-15T10:23:31.955+05:30Hi forecemagic,
Thanks for your comment.
First, ...Hi forecemagic,<br /><br />Thanks for your comment.<br /><br />First, I haven't take any code from stackoverflow.<br />second, I have given total source code in the blog.<br /><br />Regards<br />Vardhan<br /><br />Vardhan DShttps://www.blogger.com/profile/06902854396009389430noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-11518758444079128722014-01-15T01:16:26.048+05:302014-01-15T01:16:26.048+05:30First, I don't understand why you do not refer...First, I don't understand why you do not reference the StackOverflow post where you took the code from.<br /><br />Second, I don't understand why you do not post directly your BaseActivity code which is what people will be looking for anyway when coming here.<br /><br />Regards.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-55544500272158985342013-09-27T21:38:40.528+05:302013-09-27T21:38:40.528+05:30Thanks for the response, I haven't checked in ...Thanks for the response, I haven't checked in the above mentioned case...<br />On press of power button understood, but not timeout..what is timeout here?Vardhan DShttps://www.blogger.com/profile/06902854396009389430noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-72619985870791029432013-09-27T15:33:06.791+05:302013-09-27T15:33:06.791+05:30I found if you lock screen by Power button or time...I found if you lock screen by Power button or timeout, it will not show toast message.MOJOShttps://www.blogger.com/profile/00196776758312576157noreply@blogger.comtag:blogger.com,1999:blog-4023775337223455601.post-9319787778879917442013-06-26T07:23:39.470+05:302013-06-26T07:23:39.470+05:30You're right, my intention is not to call meth...You're right, my intention is not to call method initial stage. so the method won't be called when app launch or process killed also.<br />Thanks for the information :)Vardhan DShttps://www.blogger.com/profile/06902854396009389430noreply@blogger.com