android - showing rewarded video ads after click list

前端 未结 2 1615
终归单人心
终归单人心 2021-01-29 13:33

I have a list of items at homepage and when clicked will go to the activity detail. Before that I want to add Rewarded Video Ads, but with a limit after the user 3x

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-29 14:20

    Try to use this code :

         Button button = findViewById(R.id.button_id);
         int click = 0 ;
         button.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                if(click > 3){
                //show ads
                }else{
                 click++ ;
                }
             PreferenceManager.getDefaultSharedPreferences(MainActivity.this)
            .edit().putString(key, value).apply();
    
             }
         });
    

提交回复
热议问题