Rusty Well-Known Member Licensed User Longtime User Jan 14, 2011 #1 Is there a way, during Activity_Create/firsttime, to determine: Device type Device screen size/resolution Device orientation ? Thanks
Is there a way, during Activity_Create/firsttime, to determine: Device type Device screen size/resolution Device orientation ? Thanks
alfcen Well-Known Member Licensed User Longtime User Jan 14, 2011 #2 Please give this a try: Code: Dim lv As LayoutValues lv = GetDeviceLayoutValues Log(lv) As for device orientation: Code: If Activity.Width > Activity.Height Then landscape = true Else landscape = false End If Upvote 0
Please give this a try: Code: Dim lv As LayoutValues lv = GetDeviceLayoutValues Log(lv) As for device orientation: Code: If Activity.Width > Activity.Height Then landscape = true Else landscape = false End If
Erel B4X founder Staff member Licensed User Longtime User Jan 15, 2011 #4 Note that you should not check these values only when FirstTime is true. When the device is rotated the activity is recreated and FirstTime will be false. Upvote 0
Note that you should not check these values only when FirstTime is true. When the device is rotated the activity is recreated and FirstTime will be false.
Rusty Well-Known Member Licensed User Longtime User Jan 15, 2011 #5 Thanks, Erel. I discovered this and have a check in the Activity_Resume. This seems to work pretty well. Upvote 0
Thanks, Erel. I discovered this and have a check in the Activity_Resume. This seems to work pretty well.
Erel B4X founder Staff member Licensed User Longtime User Jan 16, 2011 #6 The best place to check it is in Activity_Create: Code: Sub Activity_Create (FirstTime As Boolean) If FirstTime = True Then 'here you should initialize process global objects End If 'Load layout and configure it Dim lv As LayoutValues lv = GetDeviceLayoutValues Log(lv) ... End Sub Activity_Create will always be called when the orientation is changed. Setting the layout in Activity_Resume will also work but is less efficient as Activity_Resume can be called many times (each time your activity becomes visible). Upvote 0
The best place to check it is in Activity_Create: Code: Sub Activity_Create (FirstTime As Boolean) If FirstTime = True Then 'here you should initialize process global objects End If 'Load layout and configure it Dim lv As LayoutValues lv = GetDeviceLayoutValues Log(lv) ... End Sub Activity_Create will always be called when the orientation is changed. Setting the layout in Activity_Resume will also work but is less efficient as Activity_Resume can be called many times (each time your activity becomes visible).
Rusty Well-Known Member Licensed User Longtime User Jan 16, 2011 #7 Thanks, Erel. Good information. Can you tell me what the purpose of the Activity_Resume multiple calls is. Upvote 0
Thanks, Erel. Good information. Can you tell me what the purpose of the Activity_Resume multiple calls is.
Erel B4X founder Staff member Licensed User Longtime User Jan 16, 2011 #8 See this tutorial: http://www.b4x.com/forum/basic4andr...87-android-process-activities-life-cycle.html In a brief, each time your activity is going to the background Activity_Pause is called and when it becomes visible Activity_Resume is called. The activity might be destroyed in between so these are important methods. Upvote 0
See this tutorial: http://www.b4x.com/forum/basic4andr...87-android-process-activities-life-cycle.html In a brief, each time your activity is going to the background Activity_Pause is called and when it becomes visible Activity_Resume is called. The activity might be destroyed in between so these are important methods.