android-activitylifecyclecallbacks-compat icon indicating copy to clipboard operation
android-activitylifecyclecallbacks-compat copied to clipboard

Using this on Actvity level?

Open thevirus20 opened this issue 9 years ago • 4 comments

Hi, Can I use this on Activity Level not on Application Level? I mean, suppose I am not using Application class and registering this in Activity A(Main-> Activity A) like this

ApplicationHelper.registerActivityLifecycleCallbacks(mApplication, mActivityLifecycleCallbacks);

in OnCreate() to get only call back of this activity?

I actually tried this but I am getting callback from Main also.

Is there a way to do thit?because I need to stop request if user goes away from Activity A and resume request when he comes back.

Thanks.

thevirus20 avatar Aug 19 '15 21:08 thevirus20

Why don't you simply start / stop monitoring in your Activity's onResume() / onPause()?

BoD avatar Aug 19 '15 21:08 BoD

Its a library I m working on, so I can't tell everyone that manage request on our own.

I need to detect that and manage if the Activity requesting service is active or hidden with some other activity of the app or any other app.

thevirus20 avatar Aug 19 '15 21:08 thevirus20

It should be like a Live Score, If I am checking it, its get refreshed automatically, but if I get a call(scores activity is hidden) so refresh should stop, but after I go back there again it should then immediately refresh and show me current score.

thevirus20 avatar Aug 19 '15 21:08 thevirus20

One more thing, Do I need to override method onResume(), onPause() etc. in activity if I m not extending LifecycleDispatchActivity on PRE_ICS devices to get callbacks? On POST_ICS devices, if I don't override the lifecycle method, I get the callbacks for all methods.But this is not the case in PRE_ICS. As I see you have written that in order to get callback.

Is there a way to directly get the callback on PRE_ICS devices like we get on POST_ICS devices without overriding each of lifecycle methods in activity class?

thevirus20 avatar Aug 20 '15 09:08 thevirus20