android-orientation

How do I preserve the state of a selected spinner/dropdown item on orientation change?

梦想与她 提交于 2019-11-26 20:57:33
问题 I am using a spinner dropdown in my code , in which I have 4 to 5 dynamically populated values, say if I have "apples" set to default and I select "oranges" from the dropdown and rotate my screen to landscape from portrait, it goes back to default "apples" along with the view associated with it.How do I save the state such that when I select "oranges" and rotate to landscape, it populates the selected value/remains in the same selected state and keeps the view intact/populates the view that

Android - switching between landscape and portrait mode makes Intent lose values

霸气de小男生 提交于 2019-11-26 19:52:17
问题 I am using Intents to switch between activities in my Android app. I am putting data in the Intent for use in the next activity. When I switch the phone between landscape and portrait modes, the values passed from the intent are lost and I get a NullPointerException. Can someone please tell me what could be wrong. There's a lot of code to post it entirely. But if someone needs to look at specific parts of code, I can post it here. Edit I solved the issue of state not being saved. But another

OpenCV camera orientation issue

不问归期 提交于 2019-11-26 19:19:46
问题 I have a simple project that just show the camera with org.opencv.android.JavaCameraView. my problem is that in default the camera is on landscape mode and I can't change this cause I need to define CameraBridgeViewBase instead of a regular camera intent. this is a part of my code: XML code: <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" > <org.opencv.android.JavaCameraView android:layout_width="fill_parent" android:layout_height="300dp" android

Rotating phone quickly 180 degrees, camera preview turns upside down

最后都变了- 提交于 2019-11-26 19:05:34
I have a custom camera application. When I rotating the phone by 90, camera preview works fine. But when I rotate phone quickly 180 degree, camera preview turns upside down. Is there any solution... Here is my code below: public class CustomCameraActivity extends Activity implements SurfaceHolder.Callback { Camera camera; SurfaceView surfaceView; SurfaceHolder surfaceHolder; boolean previewing = false; LayoutInflater controlInflater = null; private Sensor mOrientaion1; int cameraId = 0; public final String TAG = "CustomCamera"; private SensorManager sensorManager; @Override public void

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

。_饼干妹妹 提交于 2019-11-26 18:22:56
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 initPhotoCamera() { try { camera = getCameraInstance(selected_camera); Camera.Parameters parameters = camera

Restoring state of TextView after screen rotation?

淺唱寂寞╮ 提交于 2019-11-26 15:55: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? 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 in addition to meta-data such as the current cursor position. By default this is disabled; it can be useful

Fool-proof way to handle Fragment on orientation change

守給你的承諾、 提交于 2019-11-26 14:56:01
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, myFragment); //add content DetailPart1 content1= new DetailPart1 (); fragmentTransaction.add(R.id.content

Force an Android activity to always use landscape mode

风流意气都作罢 提交于 2019-11-26 11:04:36
I am using the Android VNC viewer on my HTC G1 . But for some reason, that application is always in landscape mode despite my G1 is in portrait mode. Since the Android VNC viewer is open source, I would like know how is it possible hard code an activity to be 'landscape'. I would like to change it to respect the phone orientation. Looking at the AndroidManifest.xml ( link ), on line 9: <activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:name="VncCanvasActivity"> This line specifies the screenOrientation as landscape, but author goes

EXIF orientation tag value always 0 for image taken with portrait camera app android

家住魔仙堡 提交于 2019-11-26 08:14:31
问题 I have a camera app in portrait mode which takes pictures from both front and back end cameras.I am saving the image in my sd card and try to find the corresponding exif value which gives 0 always.But i am getting the the expected exif orientation value for the other images stored in the device(like downloaded pictures). How can i fix this ? Can anyone help me out ? Here is the code used to save the picture and the find the orientation PictureCallback myPictureCallback_JPG = new

Rotating phone quickly 180 degrees, camera preview turns upside down

被刻印的时光 ゝ 提交于 2019-11-26 06:46:18
问题 I have a custom camera application. When I rotating the phone by 90, camera preview works fine. But when I rotate phone quickly 180 degree, camera preview turns upside down. Is there any solution... Here is my code below: public class CustomCameraActivity extends Activity implements SurfaceHolder.Callback { Camera camera; SurfaceView surfaceView; SurfaceHolder surfaceHolder; boolean previewing = false; LayoutInflater controlInflater = null; private Sensor mOrientaion1; int cameraId = 0;