Hello group. I'm trying to learn the first steps to be able to build by my self some java sdks wrappers, but i am lost :
1) Until a week ago, java was only a boring language stuffed with lots of {} and strange terms like decorators, implements, extents and other crazy stuff
2) More concrete samples of java lib wrappers on the forum would be pretty cool
but :
3) I'm a fast learner
4) SLC IS REALLY great
So, armed with 3 & 4, i've spent the last three hours trying to get admob Interstitials on BA.
and this, based on Erel published admobwrapper (really appreciate this)
gives me a really nice looking fullscreen ad.
Hey, it's my first lib, stop laughing.
What i would like to ask is if someone could please point me in the right direction to be able to call a B4A sub
for example here at this point :
i.e. how can i get ba.raiseEvent(getObject(), eventName + "_receivead"); working.
TIA
Nelson
1) Until a week ago, java was only a boring language stuffed with lots of {} and strange terms like decorators, implements, extents and other crazy stuff
2) More concrete samples of java lib wrappers on the forum would be pretty cool
but :
3) I'm a fast learner
4) SLC IS REALLY great
So, armed with 3 & 4, i've spent the last three hours trying to get admob Interstitials on BA.
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
'Dim a As AdView1
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim a As AdView1
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
a.Initialize("","ADMOB_ID_OF_A_INTERSTITIAL")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
and this, based on Erel published admobwrapper (really appreciate this)
B4X:
package anywheresoftware.b4a.admobwrapper;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DontInheritEvents;
import anywheresoftware.b4a.BA.Events;
import anywheresoftware.b4a.BA.Hide;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.objects.ViewWrapper;
import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import com.google.ads.*;
import com.google.ads.InterstitialAd;
/**
* The AdMob library allows you to add ads served by AdMob to your application.
*See the <link>AdMob Tutorial|http://www.b4x.com/forum/basic4android-getting-started-tutorials/7300-admob-tutorial-add-ads-your-application.html</link>.
*This library requires some additional configuration as described in the tutorial.
*This view must be set to a size of 320dip x 50dip. Otherwise it will not display.
*/
@Version(1.0f)
@ShortName("AdView1")
@Events(values={"ReceiveAd", "FailedToReceiveAd (ErrorCode As String)"})
@ActivityObject
@DontInheritEvents
@Permissions(values={"android.permission.INTERNET", "android.permission.ACCESS_NETWORK_STATE"})
@DependsOn(values={"GoogleAdMobAdsSdk-6.4.1"})
public class AdViewWrapperi {
/**
* Initializes the AdView.
*EventName - Name of Subs that will handle the events.
*PublisherId - The publisher id you received from AdMob.
*/
private InterstitialAd interstitial;
private AdListener adHook;
public class BannerExample implements AdListener {
@Override
public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode e){
//ba.raiseEvent(getObject(), eventName + "_failedtoreceivead", e.toString());
}
@Override
public void onReceiveAd(Ad ad) {
//ba.raiseEvent(getObject(), eventName + "_receivead");
interstitial.show();
}
@Override
public void onDismissScreen(Ad arg0) {
}
@Override
public void onLeaveApplication(Ad arg0) {
}
@Override
public void onPresentScreen(Ad arg0) {
}
};
public void Initialize(final BA ba, String EventName, String PublisherId) {
interstitial=(new InterstitialAd(ba.activity, PublisherId));
//super.Initialize(ba, EventName);
final String eventName = EventName.toLowerCase(BA.cul);
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
interstitial.loadAd(adRequest);
BannerExample hook = new BannerExample();
// Set Ad Listener to use the callbacks below
interstitial.setAdListener(hook);
}
/**
* Sends a request to AdMob, requesting an ad.
*/
public void LoadAd() {
AdRequest req = new AdRequest();
req.setTesting(true);
//getObject().loadAd(req);
}
}
gives me a really nice looking fullscreen ad.
Hey, it's my first lib, stop laughing.
What i would like to ask is if someone could please point me in the right direction to be able to call a B4A sub
for example here at this point :
B4X:
@Override
public void onReceiveAd(Ad ad) {
//ba.raiseEvent(getObject(), eventName + "_receivead");
interstitial.show();
}
i.e. how can i get ba.raiseEvent(getObject(), eventName + "_receivead"); working.
TIA
Nelson