R reeZZer Member Licensed User Longtime User Dec 13, 2011 #1 Hello, i'm working on a Chat APP and would like to start with the Landscape mode too. I'm using the Network Lib and on every Screen Orientation the Connection to the Active socket gets lost and ofc the views get destroyed. I found an interesting line to add in the Manifest XML: Code: android:configChanges="keyboardHidden|orientation" which will prevent the Activity to be Destroyed and an Event should be raised when the Screen Orientation change: Code: @Override public void onConfigurationChanged(Configuration newConfig) { } Is there a way to realise this in B4A without an extra Lib? (or if there is one which is the Name?) Thanks in advance.
Hello, i'm working on a Chat APP and would like to start with the Landscape mode too. I'm using the Network Lib and on every Screen Orientation the Connection to the Active socket gets lost and ofc the views get destroyed. I found an interesting line to add in the Manifest XML: Code: android:configChanges="keyboardHidden|orientation" which will prevent the Activity to be Destroyed and an Event should be raised when the Screen Orientation change: Code: @Override public void onConfigurationChanged(Configuration newConfig) { } Is there a way to realise this in B4A without an extra Lib? (or if there is one which is the Name?) Thanks in advance.
walterf25 Expert Licensed User Longtime User Dec 13, 2011 #2 Screen Orientation without destroying activity Hello friend, i'm fairly new to Basic4Android, and faced the same issue you're dealing with right now, i now use the StateManager module which has worked very well for me in most of the apps i've worked on, please take a look herehttp://www.b4x.com/forum/basic4android-getting-started-tutorials/9777-statemanager-helps-managing-android-applications-settings-state.html#post54161 Or nother way you can handle this is by using the Sub Activity_Resume and Sub Activity_Pause subs, you can declare global variables and save your information in this variables before switching screen orientation. Hope i'm making sense, let me know if you have any questions i'll be more than happy to help you out Walter Upvote 0
Screen Orientation without destroying activity Hello friend, i'm fairly new to Basic4Android, and faced the same issue you're dealing with right now, i now use the StateManager module which has worked very well for me in most of the apps i've worked on, please take a look herehttp://www.b4x.com/forum/basic4android-getting-started-tutorials/9777-statemanager-helps-managing-android-applications-settings-state.html#post54161 Or nother way you can handle this is by using the Sub Activity_Resume and Sub Activity_Pause subs, you can declare global variables and save your information in this variables before switching screen orientation. Hope i'm making sense, let me know if you have any questions i'll be more than happy to help you out Walter
Erel B4X founder Staff member Licensed User Longtime User Dec 13, 2011 #3 One solution is to use StateManager as posted above. If you want to lock the activity to landscape then you can choose Project - Supported orientations. Upvote 0
One solution is to use StateManager as posted above. If you want to lock the activity to landscape then you can choose Project - Supported orientations.
R reeZZer Member Licensed User Longtime User Dec 14, 2011 #4 Hello, i can now keep up the Network (Socket) and all other non-Activity based Functions by declaring them on Process_Globals. My actual Problem now is i'm using a Label with Richstring and ClickableTextView Library which makes the Text Colored and some Text is clickable, if i copy the whole Text and set it on Resume the Color and Clickable Text is gone. Is there any solution ? i don't think so. Thanks anyways. Upvote 0
Hello, i can now keep up the Network (Socket) and all other non-Activity based Functions by declaring them on Process_Globals. My actual Problem now is i'm using a Label with Richstring and ClickableTextView Library which makes the Text Colored and some Text is clickable, if i copy the whole Text and set it on Resume the Color and Clickable Text is gone. Is there any solution ? i don't think so. Thanks anyways.
R Roger Garstang Well-Known Member Licensed User Longtime User Sep 28, 2012 #5 Did a means to gain access to onConfigurationChanged ever get added to B4A or a library? I tried this on one activity and it is an interesting effect if I could just get an event to know when to resize/move my controls. PhoneSensors is as closes as I've found, but the results from it are hard to process. I'd rather get an event just at the four positions like getRotation returns. Upvote 0
Did a means to gain access to onConfigurationChanged ever get added to B4A or a library? I tried this on one activity and it is an interesting effect if I could just get an event to know when to resize/move my controls. PhoneSensors is as closes as I've found, but the results from it are hard to process. I'd rather get an event just at the four positions like getRotation returns.
Erel B4X founder Staff member Licensed User Longtime User Sep 29, 2012 #6 onConfigurationChanged event is currently not exposed. Why do you need it? Why not manage the layout in Activity_Create? Upvote 0
onConfigurationChanged event is currently not exposed. Why do you need it? Why not manage the layout in Activity_Create?
R Roger Garstang Well-Known Member Licensed User Longtime User Sep 30, 2012 #7 It would just be a good option to have my app not be destroyed and recreated on something as simple as a screen rotation. It would be nice to just get an Event when it happens and resize my controls. Destroying works fine for those using the designer, but for those building interfaces by code this would be much easier. Not only is it easier to manage the code, but the interface is much faster when just sizing the controls instead of them being destroyed and recreated all the time. I would much rather have my app only destroyed by the OS. It would work best to have it just like one of the Activity Events or something. If they don't use it then nothing is changed and I'd guess internally B4A would just pass the event on and the App would get destroyed as usual. Otherwise the developer can process it and pass true back to avoid the app being destroyed. That may not be the correct way it happens and/or it may need reverse logic like if passing it on does nothing then B4A may need to call something that destroys the app and calls Create/Resume again, but whatever needs done to get it shouldn't be that much. Some of the threads seem to also use it to capture keyboard events to prevent hardware keyboards from crashing the app when they fly out. The threads are a little old and I'd think that would be something big, so either it was fixed already and some code is there that could be easily tweaked to add this or this could be used to fix it too if not. Upvote 0
It would just be a good option to have my app not be destroyed and recreated on something as simple as a screen rotation. It would be nice to just get an Event when it happens and resize my controls. Destroying works fine for those using the designer, but for those building interfaces by code this would be much easier. Not only is it easier to manage the code, but the interface is much faster when just sizing the controls instead of them being destroyed and recreated all the time. I would much rather have my app only destroyed by the OS. It would work best to have it just like one of the Activity Events or something. If they don't use it then nothing is changed and I'd guess internally B4A would just pass the event on and the App would get destroyed as usual. Otherwise the developer can process it and pass true back to avoid the app being destroyed. That may not be the correct way it happens and/or it may need reverse logic like if passing it on does nothing then B4A may need to call something that destroys the app and calls Create/Resume again, but whatever needs done to get it shouldn't be that much. Some of the threads seem to also use it to capture keyboard events to prevent hardware keyboards from crashing the app when they fly out. The threads are a little old and I'd think that would be something big, so either it was fixed already and some code is there that could be easily tweaked to add this or this could be used to fix it too if not.
Informatix Expert Licensed User Longtime User Sep 30, 2012 #8 reeZZer said: I found an interesting line to add in the Manifest XML: Code: android:configChanges="keyboardHidden|orientation" which will prevent the Activity to be Destroyed and an Event should be raised when the Screen Orientation change: Click to expand... Google warns against using it: Note: Using this attribute should be avoided and used only as a last-resort. Please read Handling Runtime Changes for more information about how to properly handle a restart due to a configuration change. Click to expand... Upvote 0
reeZZer said: I found an interesting line to add in the Manifest XML: Code: android:configChanges="keyboardHidden|orientation" which will prevent the Activity to be Destroyed and an Event should be raised when the Screen Orientation change: Click to expand... Google warns against using it: Note: Using this attribute should be avoided and used only as a last-resort. Please read Handling Runtime Changes for more information about how to properly handle a restart due to a configuration change. Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Oct 1, 2012 #9 It would just be a good option to have my app not be destroyed and recreated on something as simple as a screen rotation. Click to expand... Your app is not destroyed. Only the activity. Upvote 0
It would just be a good option to have my app not be destroyed and recreated on something as simple as a screen rotation. Click to expand... Your app is not destroyed. Only the activity.
R Roger Garstang Well-Known Member Licensed User Longtime User Oct 1, 2012 #10 You know what I mean. Apps in Android exist one Activity at a time and a simple thing like a rotation shouldn't destroy the Interface. Upvote 0
You know what I mean. Apps in Android exist one Activity at a time and a simple thing like a rotation shouldn't destroy the Interface.
Ricky D Well-Known Member Licensed User Longtime User Oct 1, 2012 #11 Unfortunately that's just what android does. In Activity create try this Code: If Activity.Width>Activity.Height Then 'landscape Else 'portrait End If Regards, Ricky Upvote 0
Unfortunately that's just what android does. In Activity create try this Code: If Activity.Width>Activity.Height Then 'landscape Else 'portrait End If Regards, Ricky
R Roger Garstang Well-Known Member Licensed User Longtime User Oct 1, 2012 #12 Ricky D said: Unfortunately that's just what android does. Click to expand... Yes, it does this, but it doesn't only do this. The use of the text in this thread makes it not do this. I already have code handling the rotations. I'm just suggesting we allow both ways of doing it. There are a lot of changes coming...for those not keeping up on news look at the new Samsung Phones- They allow dragging a video window playing a video around the screen that continues to play while you are doing things. They even took it a step further and allow splitting the screen and running multiple applications at the same time. If we keep stuck in the mindset that Android Pauses Activities before starting another how is it then that multiple can run at the same time? The capabilities are there we just have to use them. On a desktop the OS is called Windows because it creates windows with a frame and a titlebar. If we made an IDE to create windows and only windows just because that is what Windows does then we'd never have full screen applications or applications with custom skins. Upvote 0
Ricky D said: Unfortunately that's just what android does. Click to expand... Yes, it does this, but it doesn't only do this. The use of the text in this thread makes it not do this. I already have code handling the rotations. I'm just suggesting we allow both ways of doing it. There are a lot of changes coming...for those not keeping up on news look at the new Samsung Phones- They allow dragging a video window playing a video around the screen that continues to play while you are doing things. They even took it a step further and allow splitting the screen and running multiple applications at the same time. If we keep stuck in the mindset that Android Pauses Activities before starting another how is it then that multiple can run at the same time? The capabilities are there we just have to use them. On a desktop the OS is called Windows because it creates windows with a frame and a titlebar. If we made an IDE to create windows and only windows just because that is what Windows does then we'd never have full screen applications or applications with custom skins.