I've been wondering how to save some library state on orientation change and found a solution posted on Stackoverflow: Android: How to declare global variables? - Stack Overflow.
I've read before about sub-classing the Application class to create what amounts to a global.
I could probably get the state from my library in Activity_Pause and save it to a B4A Process_Globals but wanted to experiment with the sub-classing of the Application class anyway.
So i created my sub-class:
And updated my manifest:
And my application force closes as soon as i try to run it!
The manifest file has been updated correctly:
I tried updating the manifest both with and with the dot in front of MyLibraryState but all that happens is a force close.
Is there any reason specific to B4A why i can't do this?
Or is it possible and i just need to experiment further?
Martin.
I've read before about sub-classing the Application class to create what amounts to a global.
I could probably get the state from my library in Activity_Pause and save it to a B4A Process_Globals but wanted to experiment with the sub-classing of the Application class anyway.
So i created my sub-class:
B4X:
package com.blah.blah;
import java.util.ArrayList;
import android.app.Application;
import anywheresoftware.b4a.BA.Hide;
@Hide
public class MyLibraryState extends Application {
// http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables
protected ArrayList<String> mValues = new ArrayList<String>();
}
And updated my manifest:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
SetApplicationAttribute(android:name, ".MyLibraryState")
And my application force closes as soon as i try to run it!
The manifest file has been updated correctly:
B4X:
<application
android:icon="@drawable/icon"
android:label="Oregon Jobs"
android:name=".MyLibraryState">
I tried updating the manifest both with and with the dot in front of MyLibraryState but all that happens is a force close.
Is there any reason specific to B4A why i can't do this?
Or is it possible and i just need to experiment further?
Martin.