Lu Maw Lu Maw -4 years ago 74
Android Question

Play button not working again after clicked "Back" button

I loaded Interstitial Ads at onCreate method as following,

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.singlechannel_activity);

mAdView = (AdView) findViewById(R.id.adView);
mAdView.loadAd(new AdRequest.Builder().build());
mInterstitial.setAdUnitId(getResources().getString(R.string.admob_intertestial_id));
mInterstitial.loadAd(new AdRequest.Builder().build());
mInterstitial.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// TODO Auto-generated method stub
super.onAdLoaded();
}
});


And show ads trigger to Play button to show Interstitial ads before playing video.
Here is code to show ads which trigger to Play button..

img_ply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (mInterstitial.isLoaded()) {
mInterstitial.show();
mInterstitial.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
Intent inttv = new Intent(SingleChannelActivity.this, TvPlay.class);
inttv.putExtra("url", ChannelUrl);
startActivity(inttv);
}
});
}
}
});


Ads show pretty fast instantly, and then proceed to video perfectly but Problem is after playing video, user click "Back" button and after that Play button doesn't working anymore and cannot click on that again. Could you please show me example how to work that button again...???

Answer Source

something like this

img_ply.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        if (mInterstitial.isLoaded()) {
            mInterstitial.show();
            mInterstitial.setAdListener(new AdListener() {
                @Override
                public void onAdClosed() {
                    super.onAdClosed();
                        Intent inttv = new Intent(SingleChannelActivity.this, TvPlay.class);
                        inttv.putExtra("url", ChannelUrl);
                        startActivity(inttv);
                }
            });
        }else{
              Intent inttv = new Intent(SingleChannelActivity.this, TvPlay.class);
                        inttv.putExtra("url", ChannelUrl);
                        startActivity(inttv);

        }
    }
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download