我怎么能代替type_orientation(是去precated)为Android 4.0.3?我怎么能、type_orientation、precated、Android

2023-09-05 11:00:18 作者:换我心为你心

您好我想使用的类型 type_orientation 但pcated为Android 4.0.3去$ P $。我将其用于增强现实。我试图在网络上找到,但没有成功。我的应用程序的工作,但我的在同一个地方的文字里面逗留!在这里,我的code:

Hello I want to use the type type_orientation but it is deprecated for the android 4.0.3 . I use it for the augmented reality. I tried to find on the net but without success. My application works but my text inside stay in the same place! Here my code:

 @Override
    protected void onStart() {      
        super.onStart();
        sensorMngr = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        sensorLstr = createListener();
        sensorMngr.registerListener(sensorLstr, sensorMngr.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_UI);
    }

    @Override
    protected void onStop() {       
        super.onStop();
        sensorMngr = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        sensorMngr.unregisterListener(sensorLstr, sensorMngr.getDefaultSensor(Sensor.TYPE_ORIENTATION));        
    }

这一切都好嘛只是这一点,我已经枕着http://developer.android.com/reference/android/hardware/Sensor.html,但我一点都不懂(我为法国和我的英语还不是很完美的......)非常感谢你的帮助!

Everything it s good just this, i looked already on http://developer.android.com/reference/android/hardware/Sensor.html, but i can t understand (I m french and my english is not very perfect...) Thank you very much for your help!!!

推荐答案

这里有一个链接以一个可以解决的博客。从本质上讲,你停止使用方向传感器,并使用磁场传感器和加速度传感器(S)的串联来获得同样的功能。这是更多的工作,但它允许你继续使用一个回调来处理方向改变。

Here's a link to a blog with a solution. Essentially, you stop using the Orientation Sensor and use the Magnetic Field Sensor and Accelerometer Sensor(s) in tandem to get equivalent functionality. It's more work but it does allow you to continue to use a callback to handle orientation changes.

 
精彩推荐
图片推荐