playing video while changing to landscape mode android - android

I am using Listview
I'm playing video (on VideoView) on portrait mode (not on full screen) and when I change to
landscape mode the video stop.
When I change it to landscape that video will appear on full screen and will keep playing.
Any Suggestion?

You can add this in your manifest for that activity, and ensure the activity does not redraw the views.
<activity
android:name=".YourActivityName"
android:configChanges="orientation|screenSize">
</activity>
Please note that if you have handled the orientation changes for this activity separately, then adding this would skip that.

Related

How to force activity always appear in portrait orientation without delay in lockscreen?

I have an activity with "portrait" orientation in AndroidManifest.xml.
When I start it from lock screen in landscape orientation, it appear with landscape for 1 second, and then change to portrait. The delay happens even if it's an blank activity (no view, no task).
Tell me how to avoid this delay. Remove transition effect, rotation effect? I know it could be device performance, but still want to fix this.
If you always wants to run your app in landscape mode than use this code in Manifest file for all activity
<activity
android:name=".yourAcitvity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="orientation|screenSize"
/>
That't the default behavior of Android, you can verify this issue using system apps. For ex: open the Android's default messenger, and turn it to landscape and lock the phone, now unlock it and you can see the messenger has re aligned to portrait, that's because the home screen is set to portrait by default. In order to show the home screen the system aligns the device to portrait again.

Android rotate only status bar and buttons

I decided to develop my own camera activity since I need to force the user to take a 1:1 ratio picture; just like Instagram. I created my activity based on this activity from an open-source project:
https://github.com/pocorall/scaloid-apidemos/blob/master/src/main/java/com/example/android/apis/graphics/CameraPreview.java
Now I'm trying to handle the screen rotation to avoid the layout from being rotated. In other words, I want to keep the layout from rotating and rotate only the buttons and the status bar depending on the device rotation.
I already declared my activity to listen for config changes in the manifest file.
<activity
android:name=".activity.CameraActivity"
android:configChanges="orientation|screenSize"
android:theme="#style/Theme.Eyes.NoActionBar"
android:windowSoftInputMode="adjustNothing|stateHidden">
</activity>
Stop rotation of layout
Add android:screenOrientation="portrait" into manifest
Detect rotation for individual buttons
Call Display.getRotation() to check how much the screen has roated and adjust buttons accordingly

How to change the Orientation for fragments in Android?

I have managed to change the Orientation for my fragment in my activity.
The Orientation is changed when my device is rotated.
Now I want to same functionality when I click on a button in the fragment.
i.e. I want to change from portrait mode to LandScape mode when I click on a button on the portrait layout and visa vera.
I used
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
and
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
respectively.
But this made the auto rotate functionality stop working. How can I fix this issue?
When you need auto rotating use getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
Please try this
<activity
android:name="<class name with package>"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait">

Android disable landscape mode

I wish to disable the landscape view in an android application . I've used :
<activity android:name=".SomeActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
It works but there is a slightly big problem . If I rotate the screen the activity restarts , and when it comes back , the screen is still in portrait mode . I want my app to completely ignore the device's position . There is no point in disabling the landscape view if when I rotate the device the activity restarts ( the screen becomes black for a few seconds , and then the activity appears again still in portrait mode ) .
android:configChanges="orientation|keyboardHidden|keyboard"
write a class and extend it to the activity. In that class add this code to a method.
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Then call this method to the activites to which you want to disable the landscape mode..

Is there any way to force the portrait screen even the hard keyboard is popped?

I specified an activity to be portrait-only in menifest file:
<activity android:name="mytest"
android:alwaysRetainTaskState="true"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:screenOrientation="portrait">
But it won't work on Droid when its hard keyboard is popped out.
When hard keyboard is popped out, the device always renders the layout of the activity in landscape orientation first, then it switches it back to portrait orientation. How can I let the app only render the activity in portrait orientation?
Can anyone help? Thanks.
Try using this in your activity description
android:configChanges="keyboardHidden"

Categories

Resources