rbw152 Member Licensed User Longtime User Feb 23, 2017 #1 Hi all, I'm having some issues with Android destroying and then re-creating the activity. I've been able to re-produce this issue when connecting a bluetooth barcode scanner when the activity is open. As soon as the bluetooth device connects, the activity is shut down and re-created. My dynamically generated controls (not made in designer) are therefore losing their values when the layout is re-built. I've read somewhere that the configuration state changes are detected by Android and so it restarts the activity to apply the new changes. I have added the following to the manifest file, but it has is no effect: Code: Copy AddApplicationText(<activity android:name=".FilesAndScanning" android:configChanges="orientation|keyboard|locale|mcc|mnc|uiMode|screenSize"/>) I think I may have done that wrong. I am testing this by re-orientation (which I think should be dealt with by the above manifest code). The activity is still being re-created when re-orientating the screen. Does anyone have any suggestions as to how to deal with this? Either by blocking the activity from being re-created or by preserving the value of my dynamic controls when it happens. I don't really mind. Thanks in advance
Hi all, I'm having some issues with Android destroying and then re-creating the activity. I've been able to re-produce this issue when connecting a bluetooth barcode scanner when the activity is open. As soon as the bluetooth device connects, the activity is shut down and re-created. My dynamically generated controls (not made in designer) are therefore losing their values when the layout is re-built. I've read somewhere that the configuration state changes are detected by Android and so it restarts the activity to apply the new changes. I have added the following to the manifest file, but it has is no effect: Code: Copy AddApplicationText(<activity android:name=".FilesAndScanning" android:configChanges="orientation|keyboard|locale|mcc|mnc|uiMode|screenSize"/>) I think I may have done that wrong. I am testing this by re-orientation (which I think should be dealt with by the above manifest code). The activity is still being re-created when re-orientating the screen. Does anyone have any suggestions as to how to deal with this? Either by blocking the activity from being re-created or by preserving the value of my dynamic controls when it happens. I don't really mind. Thanks in advance
eps Expert Licensed User Longtime User Feb 23, 2017 #2 Don't know about your specific 'problem' - I'm not sure I entirely follow - but I use StateManager code to keep the controls as they were.. The code is quite old now, but still works. https://www.b4x.com/android/forum/t...android-applications-settings-and-state.9777/ Upvote 0
Don't know about your specific 'problem' - I'm not sure I entirely follow - but I use StateManager code to keep the controls as they were.. The code is quite old now, but still works. https://www.b4x.com/android/forum/t...android-applications-settings-and-state.9777/
Erel B4X founder Staff member Licensed User Longtime User Feb 23, 2017 #3 You should use SetActivityAttribute to set this attribute. However I recommend you to use StateManager. Otherwise the layout will not be updated properly when the orientation changes. Upvote 0
You should use SetActivityAttribute to set this attribute. However I recommend you to use StateManager. Otherwise the layout will not be updated properly when the orientation changes.