[Solved]How can i pass on the ’Custom Class Instance’ from AdroidHarness to Simpleapplication

I should have to pass on ‘my custom class instance that own my character information’ from AndroidHarness to Simpleapplication.

How can i do this?

Please, help me to solve this problem …;

Actually you shouldn’t have to do that if you designed your application correctly. Anyway the application is a variable in the harness, there even is some getter for it, can’t remember the name right now though.

@normen said:
Actually you shouldn't have to do that if you designed your application correctly.

Thank you for your reply ^^.
Don't i need to pass on 'my custom data' from AndroidHarness to SimpleApplication??
My app have 'flow chart' that expressed by under Image
http://i.imgur.com/9ln9q.png
In SimpleApplication, i have 'Vehicle Control' which is player.
Vechicle Control have some property like stiffness, compValue , dampValue..
And user can set this value in Option Activity...
So i think custom property which is set by user should be passed to SimpleApplication via MainActivity.
Now, do i go in the wrong direction?

Read this, and make your application plataform independent so it can be easily deployed for any plataform without change your main project ;).

@glaucomardano said:
Read this, and make your application plataform independent so it can be easily deployed for any plataform without change your main project ;).

Thank you for your attention ^^.
I already read this post. But i can understand meaning of this post partially.
i think this post urge that we should use Appstate to design my application on platform independent...
Is this right?... Hmm. Is there any example for this post?
Also.. i use Elipse Tool.

Just learn about app states :P.

Yes^^ i`ll learn ‘app states’.

If all you are doing is making an Android activity to set some game options before starting the game, I would recommend using Nifty to create an options menu. This way you do not need anything Android specific.



Just my opinoin.

@iwgeric said:
If all you are doing is making an Android activity to set some game options before starting the game, I would recommend using Nifty to create an options menu. This way you do not need anything Android specific.

Just my opinoin.

Thank you for your advise ^^
@glaucomardano said:
Just learn about app states :P.

I've learned 'AppState' for all day.
This concept is difficult to understand for me.
But..I can`t understand why this can be a solution for me.

SimpleApplication is called in AndroidHarness.
[java]
public class JMEStartActivity extends AndroidHarness {
.......
public void onCreate(Bundle savedInstanceState) {
appClass = "jme3.test.appstate." + "simpleapplication" // this is a Simpleapplication;
eglConfigType = ConfigType.FASTEST;
//mouseEventsEnabled=false;
exitDialogTitle = "Exit?";
exitDialogMessage = "Press Yes";
eglConfigVerboseLogging = false;
}
....
}
[/java]
But.... i can't find any method that attach 'ApplicationState' to SimpleApplication in AndroidHarness !;;;;;
just only stateManager.attach(state) is existing only in Simpleapplication.
This method can't be a solution....
Please, I don`t understand what you mean.

You don’t attach the app state in android hardness. You just retrieve it from application object and set its parameter. The concept is on the link I gave you before :







Can’t you understand this? It means you create your abstract app states for your application, and then those app states will have different behaviors for every plataform, making this plataform independent. For example, the image above has an app state with a camImage object, then you’ll set it from your android project (or any other project plataform) and the application will use that value without knowing from where it is. You set it from your android side so:



[java]

app.getStateManager().getState(MyState.class).setMyVariable(myVariable);

[/java]



And then your app will retrieve that value indenpendently if it comes from an android app or not:



[java]

myVariable = stateManager.getState(MyState.class).getMyVariable();

[/java]

@qlaucomardano

Thank you for your attention, Always!

I can understand that.

But… i think ‘stateManager’ should have ‘MyState.class’ preparatory to calling ‘getState(MyState.class)’.

Is this right?



im now test this solution.<br /> But its not work.



First In AndroidHarness

[java]

public class JMEStartActivity extends AndroidHarness {

public MyAppState m_AppState;

@Override

public void onCreate(Bundle savedInstanceState) {

appClass = “jme3.test.appstate.” + “mytest01”; // set simpleapplication class.

eglConfigType = ConfigType.FASTEST;

exitDialogTitle = “Exit?”;

exitDialogMessage = “Press Yes”;

eglConfigVerboseLogging = false;



m_AppState = new MyAppState(“Start”);

app.getStateManager().attach(m_AppState);

app.getStateManager().getState(MyAppState.class).setText(“TestTest”);

super.onCreate(savedInstanceState);

}

[/java]

Second, In SimpleApplication (mytest01)

[java]

public class mytest01 extends SimpleApplication {

@Override

public void simpleInitApp() {

String aaa= stateManager.getState(MyAppState.class).getText();

}

[/java]

Last … In MyAppState

[java]

public class MyAppState extends AbstractAppState {

private String str_testdata;

public MyAppState(String data) {

this.str_testdata = data; }

@Override

public void initialize(AppStateManager stateManager, Application app) {

super.initialize(stateManager, app); }

public String getText(){

return this.str_testdata; }

public void setText(String data){

this.str_testdata = data; }

[/java]

Where is the problem…?

The problem is that you are retrieving the “str_testdata” before you set it.

i set “str_testdata” in constructor of MyAppState.

i think that’s not a problem.

You set here too xD



[java]

app.getStateManager().getState(MyAppState.class).setText("SSIBAL");

[/java]



Btw, what do u mean about

But it`s not work.
? Does it throws any exception. We can’t help without enough informations.

i`m sorry for writing unclearly.

Yes, it throws exception ^^

when i implement this source code

[java]

app.getStateManager().attach(m_AppState);

app.getStateManager().getState(MyAppState.class).setText("TESTTEST");

[/java]

This application is stopped…

WTF you mean about

This application is down….
.

Here is Runtime Exception Error Message ^^.

Unable to start activity ComponentInfo{jme3.test.appstate/jme3.test.appstate.JMEStartActivity}: java.lang.NullPointerException

Your app wasn’t started yet xD ?

Yes, My app occur RuntimeException Error when i call JMEStartActivity…;;;;

Is there any solution …? ;;;;

I spent all day with handing this problem… ;;;

But… This is not solved yet ;;