Members cattle, I developed a camera application , using android4.3 the API (API Level 18), normal work on android2.3 phone , but android4.1 phone and android4.3 of runtime will pop-up " application has stopped running " dialog box simulator . Log output is the time of the crash :
E / AndroidRuntime (849): java.lang.RuntimeException: startPreview failed
E / AndroidRuntime (849): at android.hardware.Camera.startPreview (Native Method)
Will use camera in the android4.3 methods and what is the difference in android2.3? How to keep camera compatibility on different versions of the system ? Thank you !
------ Solution ---------------------------------------- ----
there may be different versions of the operating system adaptation problems. You can put your camera is set to null try ( before ) in Camera.open.
------ eference --------------------------------------- < br> according to their own experience, is generally caused startPreview be called multiple times , to no error and machine related
------ eference ------------------ ---------------------
Camera object initialization , set the type SurfaceHolder object
surfaceHolder.setType (SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
------ eference --------------------------- ------------
I use a variable control startPreview be invoked only once , or collapse.
------ eference ------------------------------------ ---
This I also set up , or not
------ eference ------------------------------------ ---
startPreview call this the first time there are no open judgments Preview has stopped re- tune. .
------ eference --------------------------------------- < br> really think about the general factory and mobile phone cameras are definitely his own good debugging but you can change the code changes the logic kneeling cause other applications can change the phone to try out
------ eference ------------------------------------ ---
How do you determine Preview has not been opened ? API such a business? Thank you !
------ eference ------------------------------------ ---
------ eference ------------------------------------ ---
How do you determine Preview has not been opened ? API such a business? Thank you !
If the problem really opened multiple times , you have to ignore startPreview, you first stopPreview
------ eference ------------------ ---------------------
systems are not compatible yet
没有评论:
发表评论