Starting an other activity out of jme3 "urgent"

Hello comunity
I’ve got an urgent problem
I have to start a none JME3 activity out of JME3 Engine.

can anyone help me with this? any ideas will be helpful

iam working in eclipse, so i thought it shouldn’t be a problem to start an activity out of JME3 but it is.
the normal way in android as far as i know(as i did) is generating an intent and use startActivity

[java]
//example starts an other activity in eclipse
Intent intent1 = new Intent(this, com.example.Interferenz.InterferenzActivity.class);
intent1.putExtra(“objekt”,(byte)1);
startActivity(intent1);
[/java]

I tried in simpleapplication: doesnt work
[java]
@Override
public void simpleUpdate(float tpf) {
time+=tpf;
if (time>=3){
checkPosition();
time=0;
System.out.println(object1.distanceSquared(myPlayer.getWorldTranslation()));
}
if(!gameStarted){
if (object1.distanceSquared(myPlayer.getWorldTranslation())<=100f){
System.out.println(“YES!”);
gameStarted=!gameStarted;
Intent intent1 = new Intent(this, com.example.Interferenz.InterferenzActivity.class);
intent1.putExtra(“objekt”,(byte)1);
startActivity(intent1);
}
}
}
[/java]

I tried in oncreate: doesnt work
[java]
package com.example.game;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import com.jme3.app.AndroidHarness;

public class GameActivity extends AndroidHarness {
public GameActivity () {
appClass = com.example.game.Game.class.getName();
screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent1 = new Intent(this, com.example.Interferenz.InterferenzActivity.class);
    intent1.putExtra("objekt",(byte)1);
    startActivity(intent1);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}
[/java]

I think i read the whole forum to find anything about this
I am really lost at the moment

Ok I solved this issue.

It seems it is not possible to start an activity out of simpleapp (opengl Exception).
The trick to start an other activity is:Make use of the “extends AndroidHarness” class.
AndroidHarness extends activity so it is possible to use startActivity there.

How to handle this now?
Ppass the JME Application to the “extends SimpleApplication” class.
Writte an own method which can be called from the “AndroidHarness” class and pass the activity to it.
SimpleApplication class now have access to “AndroidHarness” methods.
Now make a normal call (simpleUpdate) in SimpleApplication class of a AndroidHarness method.

My JME3 startActivity:
[java]
package com.example.game;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;

import com.jme3.app.AndroidHarness;
import com.jme3.app.Application;

public class GameActivity extends AndroidHarness {
private GameActivity myActivity;

public GameActivity () {
    appClass = com.example.game.Game.class.getName();
    screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    myActivity = this;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((Game)getJmeApplication()).meineInitialisierung(this); //this makes the AndroidHarness class available in SimpleApplication class
}

 //this calls an other android activity class, check android developer for more help
public void startInterferenz1(){
	Intent intent1 = new Intent(myActivity, com.example.Interferenz.InterferenzActivity.class);
	intent1.putExtra("objekt",(byte)1);
	myActivity.startActivity(intent1); 
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}
[/java]

My JME3 SimpleApplication class:
[java]

public class Game extends SimpleApplication {
private GameActivity mActivity;
//… normal code …

public void meineInitialisierung(GameActivity activity){
mActivity=activity;
}

float time=0;
Vector3f object1= new Vector3f(-343f,8.5f,224f);
boolean gameStarted=false;

@Override
public void simpleUpdate(float tpf) {
time+=tpf;
if (time>=3){
checkPosition();
time=0;
System.out.println(object1.distanceSquared(myPlayer.getWorldTranslation()));
}
if(!gameStarted){
if (object1.distanceSquared(myPlayer.getWorldTranslation())<=100f){
System.out.println(“YES!”);
gameStarted=!gameStarted;
mActivity.startInterferenz1(); //this calls the AndroidHarness class method
}
}
}

private void checkPosition(){
try{
System.out.println("myPlayer: "+myPlayer.getWorldTranslation());
System.out.println("Camera: "+camNode.getWorldTranslation());
}
catch(Exception except){
}
}
}
[/java]

woks for me :wink:

One thing is not working for me.

How does your Game class see your AndroidHarness class? I mean exactly this line:
private GameActivity mActivity;
Did you import that GameActivity class? Do you have them in one project?

I followed the instructions on jme3 tutorials page and I have 2 separate projects: one with JME3 Game and one with Android code. I cannot import that class because it is in another project. And I can’t add android project to game project build path, because I need that in another direction and there has to be no cycles between projects. In my case android project has to have game project in build path to be able to call some methods I use.

Thanks