Accessing android methods (noob questions)

Okay, so I just started messing around with Android recently (I’m pretty sure I’ve read all of the documentation on it for JMonkey). But I have a question that is probably too simple to cover.

In the MainActivity you are able to use these, for example,
[java]import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;[/java]

But outside of it, in your main set of classes for your project, you cannot. Right? So how do you access those classes and methods? How does the integration work between the two? I’m so confused…

Thanks!

EDIT: Oh, forgot to mention, I have NBAndroid working. Still not able to import and access those classes specific to android.

You can’t use these on the JME side.
If you want to detect touch events, use a TouchListener.
If you want to have a particular layout, make in on the JME side using Nifty or W/e GUI that suits you.

If you absolutely want to use android views to make your layout, you’ll have to do it on the android side by overriding methods of the AndroidHarness, but be aware that’ doing this you will loose any chance of portability for your application, it won’t work the same on desktop and on android, (and iOS once we have it).

1 Like

Thanks, that got me in the right direction. I eventually used,
[java]
((MainApplication) this.getJmeApplication()) // used this in my Main Activity to get my application.
[/java]
to get my MainApplication and my Main Activity communicating.