sensormanager

Get device angle by using getOrientation() function

不羁岁月 提交于 2019-11-30 07:13:26
I was using Sensor.TYPE_ORIENTATION to determine current angle of device but TYPE_ORIENTATION is deprecated on API version 8 . In SensorManager manual it refers to getOrientation() function in order to use TYPE_ORIENTATION . Here is the manual Here is my old code : public void onSensorChanged(SensorEvent event) { Log.d("debug","Sensor Changed"); if (event.sensor.getType()==Sensor.TYPE_ORIENTATION) { Log.d("debug",Float.toString(event.values[0])); float mAzimuth = event.values[0]; float mPitch = event.values[1]; float mRoll = event.values[2]; Log.d("debug","mAzimuth :"+Float.toString(mAzimuth))

Android SensorManager strange how to remapCoordinateSystem

╄→尐↘猪︶ㄣ 提交于 2019-11-28 16:07:24
API Demos -> Graphics -> Compass It works properly only, until you don't change the device natural orientation. In most phones is the portrait and most 10 inch tablets are the landscape. If you change than need to rotate this with 90 degree. I would like to see a 3D fix for that system. 100% sure need to use remapCoordinateSystem() method. I would like to see how ( code ) if I could see an explanation with how is calculated those axes mapping ( theoretical math ) it would be nice. I have tryed to understand, but I forgot all linear algebra. Here it says why must we use, but doesn't telling how

How to detect my screen orientation in portrait locked screen in android?

梦想的初衷 提交于 2019-11-27 14:27:45
I want to find the camera screen orientation in locked portrait orientation mode, well I am using camera in my fragment class and I have already set my screen orientation as portrait, but the problem I am facing is, when I turn my camera from portrait to landscape its getting changed and I need to set capture button visible only when the camera is in portrait mode. Can anyone help me to get the orientation changes in portrait mode? Below is my code: getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); sensorManager.registerListener(new SensorEventListener() { int

Turn off screen programmatically when face is close the screen on Android

人走茶凉 提交于 2019-11-27 11:36:12
My app is a dialer and when user holding the phone near his head I need to turn screen off and prevent clicking on the controls - like native Android dialer behavior. What API level I need and how can I do this in right way? I found solution by disassembling one very famous VoIP application. This activity after pressing button1 will disable screen and hardware keys when you close sensors. After pressing button2 this function will be switched off. Also, this function required permission: <uses-permission android:name="android.permission.WAKE_LOCK" /> Activity. Try it. public class MainActivity

Android SensorManager strange how to remapCoordinateSystem

谁都会走 提交于 2019-11-27 09:33:19
问题 API Demos -> Graphics -> Compass It works properly only, until you don't change the device natural orientation. In most phones is the portrait and most 10 inch tablets are the landscape. If you change than need to rotate this with 90 degree. I would like to see a 3D fix for that system. 100% sure need to use remapCoordinateSystem() method. I would like to see how ( code ) if I could see an explanation with how is calculated those axes mapping ( theoretical math ) it would be nice. I have

Turn off screen programmatically when face is close the screen on Android

て烟熏妆下的殇ゞ 提交于 2019-11-26 18:03:41
问题 My app is a dialer and when user holding the phone near his head I need to turn screen off and prevent clicking on the controls - like native Android dialer behavior. What API level I need and how can I do this in right way? 回答1: I found solution by disassembling one very famous VoIP application. This activity after pressing button1 will disable screen and hardware keys when you close sensors. After pressing button2 this function will be switched off. Also, this function required permission:

How to detect my screen orientation in portrait locked screen in android?

余生颓废 提交于 2019-11-26 16:45:21
问题 I want to find the camera screen orientation in locked portrait orientation mode, well I am using camera in my fragment class and I have already set my screen orientation as portrait, but the problem I am facing is, when I turn my camera from portrait to landscape its getting changed and I need to set capture button visible only when the camera is in portrait mode. Can anyone help me to get the orientation changes in portrait mode? Below is my code: getActivity().setRequestedOrientation