Android Tutorial LibDisplay Module

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:

B4X:
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
    2.2 KB · Views: 965

COBRASoft

Active Member
Licensed User
Longtime User
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
Top