Home>
I can't move the camera and compass at the same time

I am developing a game using a camera and a geomagnetic sensor as a university subject.
I was able to write the working part of the game without any problems, but by all means
I can't operate the camera and compass at the same time ...

If i run it with the following code, the main xml will be displayed as it is and will not change.
The camera preview just keeps showing the image as a background.
Conversely, if you comment out request () and remove it, the game part will work properly. The game part mainly directs the ImageViews assigned in onCreate in onSensorChanged by operating Animation etc. when the geomagnetic sensor changes. And, of course, the camera image does not flow and the background is pitch black.

How can I get the camera and game running at the same time?
We would appreciate your cooperation.

Corresponding source code
  @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        setContentView (R.layout.activity_main);
        compassimage = (ImageView) findViewById (R.id.compass_image);
        frameimage = (ImageView) findViewById (R.id.frame_image);
        monimage = (ImageView) findViewById (R.id.monstar_image);
        monimage.setVisibility (View.GONE);
‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥
‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥
‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥‥
        DegreeTV = (TextView) findViewById (R.id.DegreeTV);
        SensorManage = (SensorManager) getSystemService (SENSOR_SERVICE);
        request ();
    }
What I tried
  • Describe setContentView (... DegreeTV);in request ()
    The result was the same.

  • Insert a method such as Image assignment after request such as Camera Preview class
    Repeated operation stopped due to unknown error -22.
    Confirmed with a physical terminal (SO-01J And.ver.8.0) and multiple emulators.

Add methods other than ImageView operations in the -onSensorChanged function
When we added a vibration function that moves according to the value of the geomagnetic sensor, we confirmed that only the vibration works even after request (). In other words, the geomagnetic sensor and onSensorChanged itself are working, and the fact that ImageView is not working in it means that something irregular is occurring in the ImageView substitution part.