Jan 16, 2012 Replies: 3 This is a little module I just made while learning how to use the Reflection library. I was interested in the GetRotation method of the Display class. But I added two more methods: GetRefreshRate and GetPixelFormat, just for completion. I couldn't make GetRectSize or GetSize to work, but that's not very important, since there are other ways to get that info (via GetDeviceLayoutValues for example). There are 2 variation of the Subs. The second one should be faster, because it doesn't need to retrieve the display each time, since it's a costly process. This way if you need to call these functions several times, you can retrieve the display at the beginning by calling getDefaultDisplay() and pass it as an argument to the second variation of the sub. Theses are the Subs in the module: Code: Copy getDefaultDisplay() As Object getPixelFormat() As Int getPixelFormat2(display As Object) As Int getRefreshRate() As Int getRefreshRate2(display As Object) As Int getRotation() As Int getRotation2(display As Object) As Int Attached is a full example, that uses the documented module. It obviously needs Reflection Library installed. enjoy! Attachments LibDisplay-0.1.zip LibDisplay-0.1.zip 2.2 KB · Views: 1,379 Click to expand...
This is a little module I just made while learning how to use the Reflection library. I was interested in the GetRotation method of the Display class. But I added two more methods: GetRefreshRate and GetPixelFormat, just for completion. I couldn't make GetRectSize or GetSize to work, but that's not very important, since there are other ways to get that info (via GetDeviceLayoutValues for example). There are 2 variation of the Subs. The second one should be faster, because it doesn't need to retrieve the display each time, since it's a costly process. This way if you need to call these functions several times, you can retrieve the display at the beginning by calling getDefaultDisplay() and pass it as an argument to the second variation of the sub. Theses are the Subs in the module: Code: Copy getDefaultDisplay() As Object getPixelFormat() As Int getPixelFormat2(display As Object) As Int getRefreshRate() As Int getRefreshRate2(display As Object) As Int getRotation() As Int getRotation2(display As Object) As Int Attached is a full example, that uses the documented module. It obviously needs Reflection Library installed. enjoy!
C COBRASoft Active Member Licensed User Longtime User Jan 26, 2012 #3 Hi, Any way to get this working when you force the app to be only portrait? I need this for the camera with ACL. That way, I know how to rotate the taken picture. The rest of my app has to stay in portrait mode only... Greetings, Sigurd
Hi, Any way to get this working when you force the app to be only portrait? I need this for the camera with ACL. That way, I know how to rotate the taken picture. The rest of my app has to stay in portrait mode only... Greetings, Sigurd
joseluis Active Member Licensed User Longtime User Jan 26, 2012 #4 It seems that when app is forced to be in portrait mode, the getrotation method of the display class returns always 0 degrees. I've found these threads, maybe it gives you some ideas: android-disable-rotations-by-90-but-enable-rotations-by-180 mandate-android-application-to-start-portrait-only-but-ability-to-rotate-when-r android-1-6-camera-rotation android-screen-orientation 12931-app-portrait-only-but-one-activity-landscape.html 6647-orientation-accelerometer-2.html
It seems that when app is forced to be in portrait mode, the getrotation method of the display class returns always 0 degrees. I've found these threads, maybe it gives you some ideas: android-disable-rotations-by-90-but-enable-rotations-by-180 mandate-android-application-to-start-portrait-only-but-ability-to-rotate-when-r android-1-6-camera-rotation android-screen-orientation 12931-app-portrait-only-but-one-activity-landscape.html 6647-orientation-accelerometer-2.html