简体   繁体   English

android 在应用程序启动时或带到前端时启动相机活动

[英]android start camera activity on application launch or while brought to frontr

I need to start camera activity when my application is started or taken from background.当我的应用程序启动或从后台获取时,我需要启动相机活动。 How to detect it?如何检测?

Take a look at the Android activity lifecycle and you will see that overriding the onResume method in your activity so that it launches the camera intent will accomplish what you need.查看Android 活动生命周期,您会发现在活动中重写 onResume 方法以启动相机意图将完成您的需要。

Note that if you do it this way you'll likely end up in the situation where you will be constantly launching the camera whenever your activity resumes and cannot exit your application (unless you are handling that in the onActivityResult from launching the camera)请注意,如果您这样做,您很可能会遇到这样的情况:只要您的活动恢复并且无法退出您的应用程序,您将不断启动相机(除非您在启动相机的 onActivityResult 中处理它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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