screen-orientation

Android: Keep MediaPlayer running during Activity screen orientation update

旧城冷巷雨未停 提交于 2019-11-29 06:37:34
I use a MediaPlayer to play an MP3. Currently I disabled screen orientation changes by using android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" in the manifest. I do want to support landscape mode now - i.e. removed those tags - but have the problem that during the destroy/create cycle the player gets stopped and then restarted. This is okay and I actually do this even manually in onPause() to stop the player when the activity goes in the background. To keep it running during orientation changes now, I tried making it static (and using the Application

why does the gingerbread emulator orientation get stuck in apps?

狂风中的少年 提交于 2019-11-29 03:16:55
At first I thought this was a problem with my app, but it seems to be happening in any app (though interestingly, not the home screen) in the gingerbread emulator. To replicate my issue, open eclipse and fire up the android emulator for gingerbread (I'm using the "Google APIs - API Level 9" as my target) So the procedure to duplicate once the emulator loads is press LCtrl-F11 to shift orientation to landscape, then again to switch to portrait Result: In the homescreen: The view rotates to landscape, and then back to portrait, as expected In any app (i've tried browser, calculator, maps, and

Change screen orientation in Android without reloading the activity

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 02:51:57
I want to change the orientation programmatically while running my Android App, with these lines of code: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); They work so far, but the main problem is that the whole activity is reloaded when the screen orientation changes, and I don't want that. Is it possible? Thanks. EDIT: OK, after I while I found out what I was missing. I had to include also "screenSize" in the configChanges property, so having android:configChanges="orientation|screenSize" solved the

How do you force an orientation change in an Android Instrumentation test?

前提是你 提交于 2019-11-29 01:54:25
问题 I'm writing some acceptance tests for an application using the ActivityInstrumentationTestCase2 class. I want to cause an orientation change from within the test to ensure that a number of things happen. Among these things are ensuring that Activity state is preserved, but also I'd like to ensure that the appropriate layout for the orientation is used. I know I can simply test the onSaveInstanceState/onRestoreInstanceState/onPause/onResume/etc. methods to make sure instance state is preserved

Orientation change in Honeycomb

南楼画角 提交于 2019-11-28 23:16:23
I have an activity that shouldn't be recreated after an orientation change. I added the following to the activity declaration in the manifest: android:configChanges="orientation" On Android 2.3 this works perfectly. On HONEYCOMB_MR2 onCreate is called anyway when change the orientation. Is there something else that needs to be done on HONEYCOMB_MR2 to prevent recreating the activity after an orientation change? Apparently using orientation|screenSize (?) prevents onCreate on Honeycomb and (so far) does not seem to break anything in previous Android versions. android:configChanges="orientation

Android: Disable rotations by 90°, but enable rotations by 180°

余生颓废 提交于 2019-11-28 20:40:43
I would like to create an Android app (for a tablet) that should be only displayed in landscape orientation, e.g. the app should ignore rotations by 90°, but support rotations by 180°. Adding android:screenOrientation="landscape" in the manifest causes the app to ignore all rotations, (even the 180° rotations), i.e. rotating the device by 180° shows the application upside down. Without the android:screenOrientation attribute my app is displayed "correctly" in all four positions. Rotation the device by 180° flips the UI vertically resp. horizontally. When rotation the device the following log

Detect iPad orientation change

断了今生、忘了曾经 提交于 2019-11-28 18:53:56
问题 How to detect with javascript or jquery when user turns iPad from vertical position to horizontal or from horizontal to vertical? 回答1: Try $(window).bind('orientationchange', function(event) { alert('new orientation:' + event.orientation); }); 回答2: You can detect the orientation change event using the following code: jQuery: $(document).ready(function() { $(window).on('orientationchange', function(event) { console.log(orientation); }); }); Check if device is in portrait mode function

How do I use a service to monitor Orientation change in Android

半城伤御伤魂 提交于 2019-11-28 18:22:54
I'm writing a Widget that will display a countdown timer. I have the widget working the way I want it until I flip the phone from landscape to portrait. My widget does not update and goes to it's initial state at start of the widget until an onupdate is called by my recurring alarm. I would like to call an onupdate manually once the orientation changes to update my widget I've been researching this for a while now and I've found out that I need to use a Service which will monitor the orientation changes and call my onupdate for my widget. My problem is I can't find a straight answer as to how

MPMoviePlayerController fullscreen quirk in iPad

杀马特。学长 韩版系。学妹 提交于 2019-11-28 17:56:29
问题 I want to show a MPMoviePlayerController in a view controller and let the user toggle full screen with the default controls, like the YouTube app. I'm using the following code in a bare-bones example: - (void)viewDidLoad { [super viewDidLoad]; self.player = [[MPMoviePlayerController alloc] init]; self.player.contentURL = theURL; self.player.view.frame = self.viewForMovie.bounds; self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self

iPhone - UIWindow rotating depending on current orientation?

ⅰ亾dé卋堺 提交于 2019-11-28 16:24:01
I am adding an additional UIWindow to my app. My main window rotates correctly, but this additional window I have added does not rotate. What is the best way to rotate a UIWindow according to the current device orientation? You need to roll your own for UIWindow. Listen for UIApplicationDidChangeStatusBarFrameNotification notifications, and then set the the transform when the status bar changes. You can read the current orientation from -[UIApplication statusBarOrientation] , and calculate the transform like this: #define DegreesToRadians(degrees) (degrees * M_PI / 180) - (CGAffineTransform