我在onCreate方法中加载插页式广告,如下所示,
@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();
}
});
在播放视频之前,展示广告会触发“播放”按钮以显示插页式广告。 以下是显示触发播放按钮的广告的代码..
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);
}
});
}
}
});
广告显示速度非常快,然后完美地进入视频但问题是在播放视频后,用户点击"返回"按钮,然后播放按钮不再工作,不能再次点击它。你能否告诉我如何再次使用该按钮...... ???
答案 0 :(得分:1)
类似
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);
}
}
});