Sep 15, 2017 Replies: 3 I've uploaded B4A Java library with Java source and B4A example project with source. The library sends the compass heading for which the phone is pointing. See this thread: https://www.b4x.com/android/forum/threads/phone-as-compass.83890/#post-532028 I used the sensor type TYPE_ROTATION_VECTOR rather than the usual TYPE_ACCELEROMETER and TYPE_MAGNETIC_FIELD. Barry. Click to expand...
I've uploaded B4A Java library with Java source and B4A example project with source. The library sends the compass heading for which the phone is pointing. See this thread: https://www.b4x.com/android/forum/threads/phone-as-compass.83890/#post-532028 I used the sensor type TYPE_ROTATION_VECTOR rather than the usual TYPE_ACCELEROMETER and TYPE_MAGNETIC_FIELD. Barry.
Erel B4X founder Staff member Licensed User Longtime User Sep 17, 2017 #2 You can use this sensor with PhoneSensors from the Phone library. Set the sensor type to 11. Note that it is only available in Android 5+. Last edited: Sep 17, 2017
You can use this sensor with PhoneSensors from the Phone library. Set the sensor type to 11. Note that it is only available in Android 5+.
canalrun Well-Known Member Licensed User Longtime User Sep 17, 2017 #3 Erel said: You can use this sensor with PhoneSensors from the Phone library. Set the sensor type to 11. Note that it is only available in Android 5+. Click to expand... That's a good point. I always forget to check for the API level for functions. If an API function requires Android 5+, the proper thing to do in B4A would be to set Min SDK Level to 21 in the Manifest Editor? My current default tester phones are all Android 5.01+. I dragged out an older phone which is Android 4.4. My example app worked. Looking at the Android documentation again I see the LocationManager stuff I use requires Android SDK level 2 or 3 or so, and the SensorManager TYPE_ROTATION_VECTOR requires Android SDK level 9 (Android version 2.3). Looking at my test app in the Manifest Editor, I have android:minSdkVersion="5". I should probably set android:minSdkVersion to 9? Barry. Last edited: Sep 17, 2017
Erel said: You can use this sensor with PhoneSensors from the Phone library. Set the sensor type to 11. Note that it is only available in Android 5+. Click to expand... That's a good point. I always forget to check for the API level for functions. If an API function requires Android 5+, the proper thing to do in B4A would be to set Min SDK Level to 21 in the Manifest Editor? My current default tester phones are all Android 5.01+. I dragged out an older phone which is Android 4.4. My example app worked. Looking at the Android documentation again I see the LocationManager stuff I use requires Android SDK level 2 or 3 or so, and the SensorManager TYPE_ROTATION_VECTOR requires Android SDK level 9 (Android version 2.3). Looking at my test app in the Manifest Editor, I have android:minSdkVersion="5". I should probably set android:minSdkVersion to 9? Barry.
Erel B4X founder Staff member Licensed User Longtime User Sep 17, 2017 #4 You are correct. It is available from Android 2.3. There is a similar named constant that is only available from Android 5 which got me confused...
You are correct. It is available from Android 2.3. There is a similar named constant that is only available from Android 5 which got me confused...