android-orientation

Controlling the camera to take pictures in portrait doesn't rotate the final images

送分小仙女□ 提交于 2019-11-26 06:16:35
问题 I\'m trying to controlling the Android camera to take pictures in a portrait app, but when I save the picture, it\'s in landscape. I\'ve rotated the image 90 grades with setCameraDisplayOrientation() method, but doesn\'t work. Then I\'ve found this post but the TAG_ORIENTATION is 0 (undefined). If I catch this value and apply a rotation value, doesn\'t work either. How I can take a photo in portrait and save it with a good orientation? /** Initializes the back/front camera */ private boolean

Restoring state of TextView after screen rotation?

谁说我不能喝 提交于 2019-11-26 06:00:01
问题 In my app I have TextView and EditText . Both have data in it. When the screen orientation changes the data in the EditText remains, but TextView data is cleared. Can some one help me out to find a way to retain data in TextView too? 回答1: If you want to force your TextView to save its state you must add freezesText attribute: <TextView ... android:freezesText="true" /> From documentation on freezesText : If set, the text view will include its current complete text inside of its frozen icicle

Fool-proof way to handle Fragment on orientation change

谁说我不能喝 提交于 2019-11-26 04:06:15
问题 public class MainActivity extends Activity implements MainMenuFragment.OnMainMenuItemSelectedListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); // add menu fragment MainMenuFragment myFragment = new MainMenuFragment(); fragmentTransaction.add(R.id.menu_fragment,

Android: Temporarily disable orientation changes in an Activity

时光毁灭记忆、已成空白 提交于 2019-11-26 03:24:41
问题 My main activity has some code that makes some database changes that should not be interrupted. I\'m doing the heavy lifting in another thread, and using a progress dialog which I set as non-cancellable. However, I noticed that if I rotate my phone it restarts the activity which is REALLY bad for the process that was running, and I get a Force Close. What I want to do is programatically disable screen orientation changes until my process completes, at which time orientation changes are

Android VideoView orientation change with buffered video

廉价感情. 提交于 2019-11-26 01:37:27
问题 I\'m trying to replicate the functionality of the latest YouTube app in the Android marketplace. When watching a video there\'s two separate layouts, one in portrait which provides additional info, and one in landscape which provides a full screen view of the video. YouTupe app in portrait mode YouTube app in landscape mode (Sorry for the randomness of the photos, but they were the first pics I could find of the actual layout) This is pretty easy to do normally - just specify an alternate

Android: Temporarily disable orientation changes in an Activity

送分小仙女□ 提交于 2019-11-26 00:25:24
My main activity has some code that makes some database changes that should not be interrupted. I'm doing the heavy lifting in another thread, and using a progress dialog which I set as non-cancellable. However, I noticed that if I rotate my phone it restarts the activity which is REALLY bad for the process that was running, and I get a Force Close. What I want to do is programatically disable screen orientation changes until my process completes, at which time orientation changes are enabled. Kevin Gaudin As explained by Chris in his self-answer , calling setRequestedOrientation(ActivityInfo

How to Disable landscape mode in Android?

寵の児 提交于 2019-11-25 23:38:42
问题 How can I disable landscape mode for some of the views in my Android app? 回答1: Add android:screenOrientation="portrait" to the activity in the AndroidManifest.xml. For example: <activity android:name=".SomeActivity" android:label="@string/app_name" android:screenOrientation="portrait" /> EDIT: Since this has become a super-popular answer, I feel very guilty as forcing portrait is rarely the right solution to the problems it's frequently applied to. The major caveats with forced portrait: This

Background task, progress dialog, orientation change - is there any 100% working solution?

依然范特西╮ 提交于 2019-11-25 22:46:50
问题 I download some data from internet in background thread (I use AsyncTask ) and display a progress dialog while downloading. Orientation changes, Activity is restarted and then my AsyncTask is completed - I want to dismiss the progess dialog and start a new Activity. But calling dismissDialog sometimes throws an exception (probably because the Activity was destroyed and new Activity hasn\'t been started yet). What is the best way to handle this kind of problem (updating UI from background

How do I disable orientation change on Android?

孤人 提交于 2019-11-25 22:01:39
问题 I have an application that I just would like to use in portrait mode, so I have defined android:screenOrientation=\"portrait\" in the manifest XML. This works OK for the HTC Magic phone (and prevents orientation changes on other phones as well). But I have a problem with the HTC G1 phone as I open the hardware QWERTY keyboard (not the virtual keyboard). My activity stays in portrait mode, but it seems to get restarted and loses all its states. This does not happen with the HTC Hero version.