android-orientation

How to switch to other activity at orientation change (and then back again)?

六眼飞鱼酱① 提交于 2019-12-24 07:03:24
问题 In my Android application I have a main activity "MyActivity" which overrides onConfigurationChanged() method. Within that method I check for a change in the orientation, if changed to landscape then I call another activity: @Override public void onConfigurationChanged(Configuration newConfig) { if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { super.onConfigurationChanged(newConfig); startActivity(new Intent(this, BaseFullScreenActivity.class)); } } Then when I change my

Force tablet to be in landscape mode

天涯浪子 提交于 2019-12-24 05:49:49
问题 Is there a way to force the tablet to be in landscape mode as default orientation when the user start's my app. Is there a way to do this with theming or something like that, so the user doent see orientation change when he is starting the app? Note: the same app is (should be) in portrait mode for phones For now I have a boolean values folder refs.xml(both values and values-large) with different value for tablet and phone, but the user can see that the app is rotating Code: public static

Fragment not re-added after orientation change

故事扮演 提交于 2019-12-24 04:02:24
问题 The Fragments in my app are not re-added to the activity's view when the device is rotated. If i understand the documentation (and similar questions here on SO) correctly, this should be handled be the fragment manager (without having to specify android:configChanges in my manifest). My Activity looks like: public class MainActivity extends SherlockFragmentActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

Switch activiy on orientation changed?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 03:53:18
问题 How can I switch to another activity when rotating the phone? My requirements: Activity A and B are portrait only Acitvity L is landscape only When landscape mode of A or B would be displayed, L is started instead. When portrait of L would be displayed, A or B are displayed. I can create this behaviour, expect for the back button. When it is pressed I'm either getting A/B in landscape or L in portrait, which I want to prevent. What I'm doing (Activities A & B, but L is similar) To trigger the

Android Orientation Change Crashes Application

与世无争的帅哥 提交于 2019-12-24 00:54:49
问题 I have an activity with simple layout file that will hold a fragment created and added to it programmatically. The fragment does not have any layout file since I create layout programmatically as shown below: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/bubble

Find out if device orientation is locked (Detect if auto-rotate is enabled/disabled)

半腔热情 提交于 2019-12-23 15:32:47
问题 How can I find out is device's screen orientation locked? I am using OrientationEventListener to trigger some actions inside my app which I would like to disable if user has his screen locked. I know I can usually can orientation like this but how to find out is this locked orientation: int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) { // It's portrait } else { // It's landscape } 回答1: Use this: if (android.provider

Cordova/Ionic - Set Portrait Only Mode for Mobiles and allow Orientation in Tablets

大城市里の小女人 提交于 2019-12-23 09:32:00
问题 How do we set Mobile phones to Portrait only and allow tablets to switch between portrait and landscape? I am using Ionic/Cordova. Currently I have configured to set the app to be in portrait mode in config.xml using the following property <preference name="orientation" value="portrait" /> 回答1: You could use isTablet plugin in conjunction with screen orientation plugin, something like: .run(function($ionicPlatform) { $ionicPlatform.ready(function() { if(window.isTablet){ screen

How EditText Retains its value but not textview when phone orientation changes?

社会主义新天地 提交于 2019-12-23 07:51:18
问题 What is so special about Edittext that it can retain the value but not Textview and some other widgets and we have to use onSavedInstance() method for them. What is the magic behind EditText specially that it can retain the values? If someone can tell how it works internally. <----Update----> How it works internally, Please point to that part of the code which explains this scenario. 回答1: What is the magic behind EditText specially that it can retain the values? How it works internally,

Keyboard disappears on orientation change

会有一股神秘感。 提交于 2019-12-22 08:28:49
问题 I have a fragment with EditText and add it into the layout using transactions. But if I rotate to landscape the soft keyboard disappears. public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (getSupportFragmentManager().findFragmentById(R.id.fragmentContainer) == null) { getSupportFragmentManager().beginTransaction() .add(R.id.fragmentContainer, new

How do I get the angle/degree of the phone with sensor/s?

喜你入骨 提交于 2019-12-22 06:27:11
问题 I am trying to get the phone angles by using TYPE_ACCELEROMETER sensor. My goal is to get the angle values only after the phone is tilted. It works, but the problem is when I put my phone facing up on the table, it still says isLandscape = true; private boolean isLandscape; mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor( Sensor.TYPE_ACCELEROMETER),1000000); private final SensorEventListener