Java Question How to make a new wrapper for Tap4Tap

MaxApps

Active Member
Licensed User
Longtime User
I am trying to figure out, how to make a wrapper for the new Tap for Tap SDK.

I have created a new JAVA project in Eclipse and added android.jar, B4AShared.jar, Core.jar, TapForTap.jar and TapForTapAdMob.jar (don´t know if the last one is needed, but it comes with the new TapForTap.jar)

Then I tried copying the code from Tap for Tap documentation (Tap for Tap), and tried to figure out, how that works, but FAILED.

I also took a look at the code from the old wrapper and tried to copy that in, instead and tried to see if I could understand enough to be able to edit it, to fit the new SDK, but FAILED.

I simply do not understand the Java code!

Kind regards
Jakob
 

MaxApps

Active Member
Licensed User
Longtime User
package dk.maxapps.maxtap4tap;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.objects.ViewWrapper;

import com.tapfortap.AdView;
import com.tapfortap.TapForTap;

@DependsOn(values={"TapForTap"})
@Permissions(values={"android.permission.INTERNET", "android.permission.ACCESS_NETWORK_STATE"})
@ActivityObject
@ShortName("TapForTap")
@Version(1.0f)

public class maxtap4tap extends ViewWrapper<AdView> {
@Override
public void Initialize(final BA ba, String AppId) {
AdView ad = new AdView(ba.activity);
setObject(ad);
super.Initialize(ba, "");
TapForTap.setDefaultAppId(AppId);
TapForTap.checkIn(ba.activity);
}
public void LoadAds() {
getObject().loadAds();
}
public void StopLoadingAds() {
getObject().stopLoadingAds();
}
}




in these 2 lines:
TapForTap.setDefaultAppId(AppId);
TapForTap.checkIn(ba.activity);
there is an error with SetDefaultAppId and chekIn - "Its says rename in file" as solution


As you can see, I have no clue about what I am doing.
 

magicuser68

Member
Licensed User
Longtime User
Wrapper code

Below you will see my version of the wrapper. The original lines which I commented out:

// TapForTap.setDefaultAppId(AppId);
// TapForTap.checkIn(ba.activity);

These are no longer used that's why you got the error.

The following line does all the work now:

TapForTap.initialize(ba.activity, (AppId));

--------------------------------------------------------
--------------------------------------------------------

package anywheresoftware.b4a.objects;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

import com.tapfortap.AdView;
import com.tapfortap.TapForTap;

@DependsOn(values={"TapForTap"})
@Permissions(values={"android.permission.INTERNET", "android.permission.ACCESS_NETWORK_STATE"})
@ActivityObject
@ShortName("TapForTap")
@Version(1.0f)
public class TapForTapWrapper extends ViewWrapper<AdView> {
@Override
public void Initialize(final BA ba, String AppId) {
AdView ad = new AdView(ba.activity);
setObject(ad);
super.Initialize(ba, "");
TapForTap.initialize(ba.activity, (AppId));

// TapForTap.setDefaultAppId(AppId);
// TapForTap.checkIn(ba.activity);
}
public void LoadAds() {
getObject().loadAds();
}
public void StopLoadingAds() {
getObject().stopLoadingAds();
}
}
--------------------------------------------------------




Also, add the following to your manifest

-------------------------------------------------
'Tap4Tap
AddApplicationText(
<activity android:name="com.tapfortap.TapForTapActivity"/>
)
-------------------------------------------------
 

Attachments

  • TapForTapWrapper.zip
    2.6 KB · Views: 296
Last edited:

MaxApps

Active Member
Licensed User
Longtime User
Thanks :)

I am trying to figure out, how it works.
When I compare your code with the documentation from Tap for Tap, I cannot recognize it.
I was hoping, that it was possible to make a wrapper, by copying the documentation and modify it a bit. But it looks like that is not possible.

Anyway.... I will try to learn more about Java and hopefully some day, I will be able to contribute to B4A community.



Kind regards
Jakob
 
Last edited:

magicuser68

Member
Licensed User
Longtime User
Look at item 2 in the documentation from Tap4Tap sdk.

You will see the following:

TapForTap.initialize(this, "YOUR API KEY");

I just copied that for the wrapper.

- Scott
 

MaxApps

Active Member
Licensed User
Longtime User
I am still looking at your code, and have made some progress.
I have managed to add appwall and help texts.
So now you can load banners and appwall
(AdTap.LoadAd or AdTap.LoadAppwall)

I have also managed to ad eventlistener for adfailed, adreceived and adtapped

I am now trying to add Interstitials. Here I have a problem.... The interstitial opens and starts loading, but only the top of it shows, and it looks like it is trying to load the rest. I am having trouble figuring this out, but I keep on trying.

So maybe I can SLOWLY learn :)

Kind regards
Jakob

Update. Well I took a look at a forum for Tap for Tap, and I am not the only one, with the interstitial problem. So I am now waiting for Tap for Tap to help me.
 
Last edited:

MaxApps

Active Member
Licensed User
Longtime User
Here is my wrapper for Tap for Tap.
All is working, except interstitials.

Kind regards
Jakob

A new wrapper is ready

Link to new wrapper


Please get the new, fully functional wrapper.
 
Last edited:
Top