android - Interstitial Ad onBackPressed from default video player -
i making tv channel streaming app when click on channel list view goes activity , pop of player selection comes , after selecting player plays video. implementing admob interstitial ad should displayed directly onbackpressed , after closing ad goes "activity a" (first activity) , not second activity b. works flawelessly when press backbutton goes second activity blank screen , on press ad.how can show ad on backpress default selected video player. here code
activty a
case 1: = new intent(a.this, b.class); i.putextra("channel","http://id=hbo"); startactivity(i); break;
activity b
bundle bundle = getintent().getextras(); string channel = bundle.getstring("channel"); uri uri = uri.parse(channel); intent intent = new intent(intent.action_view, uri); intent.setdataandtype(uri, "video/mp4"); startactivity(intent);
and onbackpressed
@override public void onbackpressed() { if (interstitial.isloaded()) { interstitial.show(); } super.onbackpressed(); }
if ad loaded show fine, still call through super.onbackpressed()
. causes activity finish , return last activity.
what need add else clause call super.onbackpressed();
if ad not loaded.
then need add listener interstitial ad listen ad closed event , call finish();
there.
Comments
Post a Comment