0

I want to access variables passed via android intents in jMonkey app. I can access these variables using the typical intent variable reading code in the MainActivity

   @Override
    public void onCreate(Bundle savedInstanceState) {
        //super.onCreate(savedInstanceState);
        Bundle parameters = getIntent().getExtras();
        System.out.println("hurr");
        if (parameters != null) {
            String name = parameters.getString("myextra");
            System.out.println(name);
            //Integer age = parameters.getInt("age");
        }
    }

However I want to access these variables in the jMonkey AppStates but I don't know how to pass references of the object holding these variables to jMonkey system. I can't access AppStateManager from the MainActivity and I can't access JmeAndroidSystem reference from the AppState using the JmeSystem object.

Is there a good way of this communication instead of hacking the AndroidHarness and JmeSystem code to make the JmeAndroidSystem visible.

simar
  • 544
  • 2
  • 7
  • 15

1 Answers1

0

JMonkey provides app variable instance in MainActivity as well.

You can use define a new AppState to store the context of Intent in OnCreate() method which can be accesses by app.getStateManager.getState(XYZ.class).

String url = getIntent().getStringExtra("url");
String uname = getIntent().getStringExtra("username");
String pass = getIntent().getStringExtra("password");
String amcatID = getIntent().getStringExtra("amcatID");
String moduleID = getIntent().getStringExtra("moduleID");

if (url!=null && uname!=null && pass!=null && amcatID!=null && moduleID!=null) {
    System.out.println("hurrhurr");
    System.out.println(url);
    System.out.println(uname);
    System.out.println(pass);
    System.out.println(amcatID);
    System.out.println(moduleID);
    app.getStateManager().attach(new SOAPCommunication(url,uname,pass,amcatID,moduleID));
}
simar
  • 544
  • 2
  • 7
  • 15