Hi,
I want to start an activity that has been initialized in Basic4Android but where the activity is in the library.
I'm doing the following:
and after initialize
This works, and this gets called:
However, with a NPE. This is because Load constructs a new Activity, so initialize is not called. I'm looking for a way that I can Initialize the class which was initialized before with the parameters, and so the EngineOptions doesn't throw a NPE, and works with the used arguments.
To conclude what i'm trying to do is extend the b4a activity instance - not create an entirely new instance of a different activity class.
So we can achieve the following
Regards,
Tomas
I want to start an activity that has been initialized in Basic4Android but where the activity is in the library.
I'm doing the following:
B4X:
public void Initialize(final BA ba, String EventName, Camera camera, EngineOptions engineOptions) {
this.ba = ba;
this.eventName = EventName;
this.camera = camera;
this.engineOptions = engineOptions;
}
and after initialize
B4X:
public Intent Load(BA pBA){
Intent intent1 = new Intent(pBA.context, RSSimpleBaseGameActivity.class);
return intent1;
}
This works, and this gets called:
B4X:
@Override
public EngineOptions onCreateEngineOptions() {
// TODO Auto-generated method stub
if (ba.subExists(eventName + "_createengineoptions")==true) {
ba.raiseEvent(this, eventName + "_createengineoptions", new Object[] { this.engineOptions });
}
return engineOptions;
}
However, with a NPE. This is because Load constructs a new Activity, so initialize is not called. I'm looking for a way that I can Initialize the class which was initialized before with the parameters, and so the EngineOptions doesn't throw a NPE, and works with the used arguments.
To conclude what i'm trying to do is extend the b4a activity instance - not create an entirely new instance of a different activity class.
So we can achieve the following
B4X:
'To start, we first have to initialize the camera and the options
'before creating our game activity.
mCamera.Initialize(0, 0, 854, 480)
mOptions.Initialize(True, True, mOptions.LANDSCAPE_FIXED, mCamera)
'Now we create our SimpleBaseGame Activity.
SimpleBaseGameActivity.Initialize("Game", mCamera, mOptions)
'We are ready to display our activity. 3 Methods will be called when constructing the activity.
'We extract an intent from the activity and use StartActivity to start it.
'Make sure to check the manifest!
StartActivity(SimpleBaseGameActivity) ' LIke this
Regards,
Tomas
Last edited: