Is it possible to determine the moment of switching of certain Activity from foreground to background and vice versa? This activity should run in the separate process.
I need to write the application that collects some statistics from using of big set of applications (app names read from configuration file). My application works as Service and should remember moments of switching of开发者_JAVA百科 activities between foreground and background. Set of applications is sufficiently big and most part of these applications will never work on certain phone.
I don't know a lot about that but I think you could try to do some digging in that direction : onFocusChangeListener by applying it to the whole activity (refered as "this" in your onCreate for instance)
What about tracking intents? If you play around on a phone or emulator while looking at LogCat, you'll see that every time an activity is started or accessed there's a log message about the intent that was broadcast. I'm not sure how your program could intercept and process these, but it's another place to start looking.
精彩评论