android-orientation

Android NullPointerException on Screen Orientation Change

ⅰ亾dé卋堺 提交于 2019-12-11 21:03:32
问题 I am narrowing down and explaining as simple as can, main activity initiates an async task. When orientation change onCreate() is recalled so Async is created once gain. so in onPreExecute() i lock my orientation and in onPostExecute() i release lock on orientation. By this way if Async task has started another instance of task will never get created. another issue has started, in main activity itself findViewById() returns null when i randomly keep changing the screen orientation. Re

How does viewPager retain fragment states on orientation change?

吃可爱长大的小学妹 提交于 2019-12-11 20:14:51
问题 This question has some similarities to: Fragment in ViewPager on Fragment doesn't reload on orientation change However the difference is that I want to know how the fragment states are actually retained as I observe a lot of weird things happening. My observations are the following: Setting up a ViewPager with a FragmentPagerAdapter: class HomeAdapter extends FragmentPagerAdapter { HomeAdapter(FragmentManager manager) { super(manager); } @Override public Fragment getItem(int i) { try { return

Adjusting layout Orientation with the device orientation in JAVA not XML

假装没事ソ 提交于 2019-12-11 16:53:04
问题 I wanted to know how i could change my LinearLayout orientation according to the device Orientation in JAVA, i found how to do it by the XML way with layout and layout-land but i didn't find how doing it by the java way. Thank you very much. 回答1: See this it describes how to Detect Orientation Changed then change orientation in java In onCreate() @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

onConfigurationChanged problems

橙三吉。 提交于 2019-12-11 16:26:14
问题 I need to change layout of my Android (4.1 API 16) application when orientation is changed. @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); setContentView(R.layout.main_2); System.out.println("Orientation changed!"); } Also I have added the next line to manifest file android:configChanges="orientation" I use Ctrl+F11 to change orientation. My screen rotates but layout stays the same and nothing is printed in LogCat. Feels like

An Android orientation glitch?

北战南征 提交于 2019-12-11 13:50:40
问题 I believe to have stumbled upon an inherent glitch in the orientation handling of Android. I have an activity A setContentView(R.layout.activity_main); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); No sensor implies that the Activity A won't be affected by the physical device rotation. I also have an activity B which has an overridden onSaveInstanceBundle /*Will be called before orientation change*/ @Override protected void onSaveInstanceState(Bundle currentState) { super

How type TYPE_ACCELEROMETER and TYPE_MAGNETIC_FIELD used to make compass on android devices

孤街醉人 提交于 2019-12-11 07:15:36
问题 I am working on an application which uses compass although I successfully implemented it but there is no such brief explanation that how it works . Like how the TYPE_ACCELEROMETER and TYPE_MAGNETIC_FIELD was used to get the orientation. I know we did get it and the zero index of the array we got is the azimuth from which we get the degree and came to know where north is. But how it get to this all. Can anyone explain please? Secondly what if I place my mobile on the floor suppose it points in

react-native-orientation-listener Cannot read property 'getOrientation' of undefined

时光总嘲笑我的痴心妄想 提交于 2019-12-11 06:37:12
问题 package.json { "name": "MakeItCluster", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "react": "15.4.1", "react-native": "0.39.2", "react-native-orientation-listener": "0.0.4", "react-native-vector-icons": "^3.0.0" }, "devDependencies": { "babel-jest": "18.0.0", "babel-preset-react-native": "1.9.1", "jest": "18.1.0", "react-test-renderer": "15.4.1" }, "jest": { "preset": "react-native" }

Android screen orientation issue in 8.1.0

ぐ巨炮叔叔 提交于 2019-12-11 05:07:00
问题 Am having issue in Android OS 8.1.0 Start a portrait activity (portrait declare on manifest) Start a landscape activity (landscape declare on manifest) Finish the landscape activity Portrait activity is showed again but the orientation start flipping: first in portrait mode, then landscape mode and finally portrait again. I had observed this issue in google pixel 2 xl device with OS version 8.1.0 onwards ( issue present in Android P developer preview1 also) i saw someone posted in google

Comparison: TYPE_ROTATION_VECTOR with Complemenary Filter

冷暖自知 提交于 2019-12-11 02:48:35
问题 I have been working on Orientation estimation and I need to estimate correct heading when I am walking in straight line. After facing some roadblocks, I started from basics again. I have implemented a Complementary Filter from here, which uses Gravity vector obtained from Android (not Raw Acceleration), Raw Gyro data and Raw Magnetometer data. I am also applying a low pass filter on Gyro and Magnetometer data and use it as input. The output of the Complementary filter is Euler angles and I am

Orientation Changes in android

懵懂的女人 提交于 2019-12-11 01:41:47
问题 I am using getLastNonConfigurationInstance() to save object while changing orientation in my activity. now it is deprecated. What is the best way of alternative? the documentation says "use Fragment". But i need to use activity. 回答1: For saving state, use onSaveInstanceState(Bundle savedInstanceState) . You can restore saved state either in onCreate or in onRestoreInstanceState(Bundle savedInstanceState) . @Override public void onSaveInstanceState(Bundle savedInstanceState) { // Save UI state