我怎么能代替type_orientation(是去precated)为Android 4.0.3? [英] How can i replace type_orientation (is deprecated) for android 4.0.3?

查看:926
本文介绍了我怎么能代替type_orientation(是去precated)为Android 4.0.3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想使用的类型 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));        
    }

这一切都好嘛只是这一点,我已经枕着<一href="http://developer.android.com/reference/android/hardware/Sensor.html">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.

这篇关于我怎么能代替type_orientation(是去precated)为Android 4.0.3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆