简体   繁体   中英

How to close/send to background Activity from another App in Android?

I am trying to build an AppLock like Android app but I encountered a difficult problem (for me): I managed somehow to detect when a given app is launched, by polling the system log, and bring to front a lock screen, on top of the launched app. My question is: how can i dissmis the launched Activity which must be protected (and, of course, the lock screen) if, for example, an invalid password is provided for the lock screen or the back button is pressed before entering a password? I have tried using killBackgroundProcess with the correct package name, but it doesn't seem to work and I can't find a relevant answer anywhere.

And one more question: is it, somehow, possible to totally prevent an app from launching, form my app rather than covering it?

Well I found an alternate solution that works like a charm! Instead of dissmising a blocked app, in case an invalid password is provided (for example), I simply bring to front the phone's home screen which implicitly sends to background the blocked app. Hope it will help others with the same issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM