I want to create a service that has a onWindowFocusChanged method, native to Activity. but our client has requested the tablet to constantly be looking for such a change in focus is there a way to add such a listener to a service or have an activity run as part of the service?
I want to create a service that has a onWindowFocusChanged method, native to Activity.
Share
Service does not have
onWindowFocusChanged()method.But you can override
onWindowFocusChanged()in your Base Activity which is parent of all your activities and notify your Service by sending Intent to it:You will receive the intent in the service via overriding
onStartCommand(Intent intent, int flags, int startId)method.