W3i offerwall sdk

时间:2012-10-27 13:21:50

标签: java android

我有一个问题,我想在我的应用中添加w3i offerwall,用于获利... 以下是sdk指南:https://associate.w3i.com/integration/index.html 我已经很容易地添加了offerwall,但是现在我必须在一个变量中进行immagazinate用户获得了什么... 指南告诉:

兑换货币 每次启动时,应用程序打开时都应进行货币兑换。 如果您正在显示商品提醒对话框,我们建议您先调用redeemCurrency()并立即使用showFeaturedOffer()进行操作。这为用户提供了逻辑流程,该用户在提示商品提醒之前从他们完成的最后一个商品中获得奖励。 处理兑换货币的方法是redeemCurrency(),它具有以下签名:

public void redeemCurrency(final Activity context, W3iCurrencyListener listener )

此方法需要当前的Activity上下文,而不是Application上下文,因为它在兑换货币时向用户显示消息对话框。此外,您需要提供W3iCurrencyListener接口的实现。 接下来,您的应用程序需要提供W3iCurrencyListener接口的实现。 W3iCurrencyListener接口用于通知游戏返回的货币。余额作为List集合返回。下面是一个示例实现:

W3iCurrencyListener callback = new W3iCurrencyListener() {
              @Override
              onRedeem(List<Balance> balances) {

                     //Take possession of the balances returned here.             

              }
};

如果您的应用程序支持多种货币,则Balance对象的集合可能适用于不同的货币类型。 如果对redeemCurrency()的调用成功,您将收到一组余额。如果没有,onRedeem()回调将不会触发。除非用户通过下载和安装应用程序转换了要约,或者为非应用程序要约完成了其他操作,否则此方法不会返回货币。

现在我不知道如何使用这段代码,如何设置返回变量?现在我希望theire办公室关闭,所以我问你... Thakns,matteo

1 个答案:

答案 0 :(得分:0)

我也面临类似的问题。我实现了他们的com.w3i.offerwall.W3iCurrencyListener并用它来调用redeemCurrency()。

我在启动器活动中调用redeemCurrency()。我的W3IListener重写onRedeem()方法。希望以下代码片段能够消除您的疑虑。

 public class MyGame extends Acitvity{
     private W3iCurrencyListener w3iListener = new W3iListener(this);
     public static int coins = 0;
     @Override
     protected void onResume(){
         try{
             w3iInstance.redeemCurrency(this, w3iListener);
         }
         catch (Exception e){
            e.printStackTrace();
         }
     }
 }


public class W3iListener implements com.w3i.offerwall.W3iCurrencyListener{

    private Context mContext = null;

    public W3iListener(Context context){
        mContext = context;
    }   


    @Override
    public void onRedeem(List<Balance> paramList) {
            if(paramList.size()>0)
            {
                int coins = 0;
                for(int i=0; i<paramList.size(); i++){
                    coins += Integer.parseInt(paramList.get(i).getAmount());
                }
                MyGame.coins = coins + MyGame.coins;
            }
    }
}