简体   繁体   English

旋转保存Android FaceDetector.Face []

[英]Saving Android FaceDetector.Face[] on rotation

I am trying to save the FaceDetector.Face array so that on a screen rotation, the facial detection does not have to be performed again. 我正在尝试保存FaceDetector.Face数组,以便在屏幕旋转时不必再次执行面部检测。 The app seems to take longer than a normal rotation. 该应用似乎比正常旋转需要更长的时间。 However, I can't store the faces array in onSavedInstanceState since it isn't serializable. 但是,我无法将faces数组存储在onSavedInstanceState因为它无法序列化。 I tried extending FaceDetector.Face with implementing serializable, but it doesn't have a default constructor. 我尝试通过实现可序列化来扩展FaceDetector.Face ,但是它没有默认构造函数。 What should I do to save an Object array like this one on rotation, that I didn't implement? 如何在旋转时保存一个我没有实现的Object数组,该如何做?

I would suggest creating a static Fragment without UI on that activity. 我建议在该活动上创建一个没有UI的静态片段。 Once you do that, you can use it to store this data. 完成此操作后,您可以使用它来存储此数据。 Keep in mind that FaceDetector.Face, is just an object that holds locations on bitmap and not the bitmap itself. 请记住,FaceDetector.Face只是一个在位图上保留位置的对象,而不是位图本身。

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

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