简体   繁体   中英

How to launch my app programmatically, if an another app opens?

I want my app automatically open when user click (for example) chrome or any other apps. How to do this? My app is for preventing people use cell phone all the time. Explicitly, there is a mission in my app. when user starts this mission, user cannot use other app until they give up the mission. User can minimize my app, but when user click another app, my app will prompt programmatically to tell user not to use the cell phone.

Instead of preventing user to launch other apps, I think you should use activities' life cycle.
You can add code in onPause() and detect user press home button or back button. And when your activity is not on foreground, you can pop a dialog or something to remind your user focus on his work not his phone.
BTW I do see the positive side of your app.

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