I am using libGDX. Created a project and there are two packages as appName, appName-android. My codes are in appName, but MainActivity.java is in the appName-android package. I set the admob advertise in the MainActivity but i don't want to have it always visible.
The question is, how can i edit adView.VISIBLE from another package? Or is it possible? How can i access MainActivity.java(in appName-android package) from a class in appName package?
Thanks in advance.
The standard way (in libGDX) to access platform-specific code (like Android adMob libraries) from your platform-independent common code is to create an interface that your common code can use, and implement the platform specific bits in an implementation of that interface.
So, create public interface AdControlInterface
that contains a method like hideAds
or whatever you want. Have the appName-android package create an Android-specific implementation of that interface and pass it into the appName package (via the constructor on the ApplicationListener
subclass you have in appName package).
Here's a tutorial on AdMob in libGDX that covers this issue (see the IActivityRequestHandler
interface) and some of the other adMob integration issues: http://code.google.com/p/libgdx/wiki/AdMobInLibgdx