title: How to auto click button when video is available in android?
body: <p>I have Integrated some rewarded video ads in my app an activity which contain a Button named as <code>Show Video</code> when I click on that I navigated to video activity which show video adds ,but problem is that Video takes time to view,I want to show a progress dialog and when <code>Videovisibilty</code> becomes "true" then hide progress dialog and auto click button to show video. </p>
  
  <p>How can I do that ?</p>
  
  <p>mainActivity code:-</p>
  
  <pre><code>  @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          _button = (Button) findViewById(R.id.show_button);
          _button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent i = new Intent(MainActivity.this, Video.class);
                  startActivity(i);
              }
          });
  
  
      }
  </code></pre>
  
  <p>Video activity code:-</p>
  
  <pre><code> String TAG = MainActivity.class.getSimpleName();
      private Supersonic mMediationAgent;
      private Placement mPlacement;
      ProgressDialog progress;
  
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          progress = new ProgressDialog(this);
          progress.setMessage("Loading video :) ");
          progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
          progress.setIndeterminate(true);
          progress.show();
  
          mMediationAgent = SupersonicFactory.getInstance();
          // Supersonic Advertiser SDK call
          SupersonicAdsAdvertiserAgent.getInstance().reportAppStarted(Video.this);
          mMediationAgent.setRewardedVideoListener(Video.this);
          final String userId = "9555515291";
          final String appKey = "50427d";
          mMediationAgent.initRewardedVideo(Video.this, appKey, userId);
          IntegrationHelper.validateIntegration(Video.this);
          if (mMediationAgent.isRewardedVideoAvailable()) {
              mMediationAgent.showRewardedVideo("DefaultRewardedVideo");
          }
  
  
      }
  
      @Override
      public void onRewardedVideoInitSuccess() {
          Log.d(TAG, "onRewardedVideoInitSuccess");
      }
  
      @Override
      public void onRewardedVideoInitFail(SupersonicError supersonicError) {
  
      }
  
      @Override
      public void onRewardedVideoAdOpened() {
          Log.d(TAG, "onRewardedVideoAdOpened");
      }
  
      @Override
      public void onRewardedVideoAdClosed() {
          // called when the video is closed
          Log.d(TAG, "onRewardedVideoAdClosed");
  
          // here we show a dialog to the user if he was rewarded
          if (mPlacement != null) {
              // if the user was rewarded
              showRewardDialog(mPlacement);
              mPlacement = null;
          }
  
      }
  
      @Override
      public void onVideoAvailabilityChanged(boolean b) {
          // called when the video availbility has changed
          Log.d(TAG, "onVideoAvailabilityChanged" + " " + b);
  
      }
  
      @Override
      public void onVideoStart() {
          // called when the video has started
          Log.d(TAG, "onVideoStart");
      }
  
      @Override
      public void onVideoEnd() {
          // called when the video has ended
          Log.d(TAG, "onVideoEnd");
      }
  
      @Override
      public void onRewardedVideoAdRewarded(Placement placement) {
          // called when the video has been rewarded and a reward can be given to the user
          Log.d(TAG, "onRewardedVideoAdRewarded" + " " + placement);
          mPlacement = placement;
      }
  
      @Override
      public void onRewardedVideoShowFail(SupersonicError supersonicError) {
          // called when the video has failed to show
          // you can get the error data by accessing the supersonicError object
          // supersonicError.getErrorCode();
          // supersonicError.getErrorMessage();
          Log.d(TAG, "onRewardedVideoShowFail" + " " + supersonicError);
      }
  
      public void showRewardDialog(Placement placement) {
          AlertDialog.Builder builder = new AlertDialog.Builder(Video.this);
          builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                  dialog.dismiss();
              }
          });
          builder.setTitle(getResources().getString(R.string.rewarded_dialog_header));
          builder.setMessage(getResources().getString(R.string.rewarded_dialog_message) + " " + placement.getRewardAmount() + " " + placement.getRewardName());
          builder.setCancelable(false);
          AlertDialog dialog = builder.create();
          dialog.show();
      }
  }
  </code></pre>