Как добавить коины за просмотр видеорекламы

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        // Declare a new listener:
        final UnityAdsListener myAdsListener = new UnityAdsListener();
        //Add the listener to the SDK:
        UnityAds.addListener(myAdsListener);
        // Initialize the SDK:
        //noinspection deprecation
        UnityAds.initialize(this, "1234567", testMode);

        // Find the button in the view hierarchy and set its click function to show ads:
        rewardedButton = (Button) findViewById(R.id.rewardedButton);
        rewardedButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //noinspection deprecation
                if (UnityAds.isReady());
                Toast.makeText(MainActivity2.this,"Ad Is Ready To be Shown",Toast.LENGTH_SHORT).show();
                UnityAds.show(MainActivity2.this);}




    // Implement a function to display an ad if the Ad Unit or Placement is ready:
    public void DisplayRewardedAd() {

         }
        });
    }

    // Implement the IUnityAdsListener interface methods:
    private class UnityAdsListener implements IUnityAdsListener {

        public void onUnityAdsReady(String surfacingId) {
            // Implement functionality for an ad being ready to show.
            rewardedButton.setEnabled(true);
        }

        @Override
        public void onUnityAdsStart(String s) {

        }

        @Override
        public void onUnityAdsFinish(String s, UnityAds.FinishState finishState) {

        }

        @Override
        public void onUnityAdsError(UnityAds.UnityAdsError unityAdsError, String s) {

        }

    }
}


Для рекламы Unity этот код  не работает
     @Override
     public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
            ((TextView) findViewById(R.id.textView))
             .setText(String.valueOf(Integer
             .parseInt(((TextView) findViewById(R.id.textView)).getText().toString()) + 5)

Ответы (0 шт):