Get points (Virtual currency Tapjoy)

Hi people! I’m having problems getting virtual currency in my app from Tapjoy, I have the “showOffers()” working well… but the problem I dont know how get the points.
I import the class to use TapjoyNotifier and implements to my Activity.

import com.tapjoy.TapjoyNotifier;

public class Main extends Activity implements TapjoyNotifier{

I implement the methods too.

Now I have to put this to obtain the points:
(http://knowledge.tapjoy.com/integration-8-x/android/publisher/virtual-currency/tapjoy-managed-currency)

TapjoyConnect.getTapjoyConnectInstance().getTapPoints(TapjoyNotifier notifier);

But sure, mi “notifier” dont exist, and I dont know how create it. I wanna show the points on a alertDialog.

If you’ve implemented the TapjoyNotifier methods in your Main class, then you should write:
[java]
TapjoyConnect.getTapjoyConnectInstance().getTapPoints(this);
[/java]
Because the keyword “this” is referring to the current instance of Main, which implements TapjoyNotifier.

Mmm well well, but I’m confused, if the method “getTapPoints()” returns void, and the abstract methods returns void too, how I can “save” the points in a int or String variable?

When you call getTapPoints() it will not give you the number of points straight away. This method just starts a background operation, which fetches the points from the server. When it’s finished, it will call the method getUpdatePoints(String currencyName, int pointTotal) in your Main class. This is where you can save the points, or display a popup, or whatever you like (pointTotal holds the number of points).

Ah wow! ok! I was misunderstanding these method! All works fine now :slight_smile: Thanks a lot again!

No worries. Glad you’ve got it up & running :slight_smile:

For future reference, might be worth reading up on how callbacks work if you’re not already familiar with the concept. A lot of Android code works in this way - you call a function, and then wait for it to “call back” with the result.

Thanks again! I read it now :slight_smile: