Difference between revisions of "Android Video"
From AdLocus
Line 10: | Line 10: | ||
private InterstitialVideoReq mInterstitialVideoReq; | private InterstitialVideoReq mInterstitialVideoReq; | ||
− | + | mInterstitialVideoReq = new InterstitialVideoReq(this, KEY, new VideoAdListener() { | |
− | + | @Override | |
− | + | public void onStart() { | |
− | + | //we will start an activity and rotate screen to landscape, | |
− | + | //make sure your code and your user are ready for a movie show! | |
− | + | mInterstitialVideoReq.show(); | |
− | + | } | |
− | + | @Override | |
− | + | public void onNofill() { | |
− | + | // 沒有廣告 | |
− | + | mInterstitialVideoReq.removeListener(); | |
− | + | } | |
− | + | @Override | |
− | + | public void onClose() { | |
− | + | // 使用者關閉廣告 | |
− | + | mInterstitialVideoReq.removeListener(); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | } | ||
+ | }); | ||
mInterstitialVideoReq.load(); | mInterstitialVideoReq.load(); |
Revision as of 17:24, 6 July 2015
前言
影音版位將以曝光次數高額分潤,是您提高收益的最好單元之一。
自我檢查
- JAR檔與 AndroidManifest.xml 是否已設定完成
啟用影音版位
在您想啟用影音版位的 Activity 中加入下列程式碼
private InterstitialVideoReq mInterstitialVideoReq; mInterstitialVideoReq = new InterstitialVideoReq(this, KEY, new VideoAdListener() { @Override public void onStart() { //we will start an activity and rotate screen to landscape, //make sure your code and your user are ready for a movie show! mInterstitialVideoReq.show(); } @Override public void onNofill() { // 沒有廣告 mInterstitialVideoReq.removeListener(); } @Override public void onClose() { // 使用者關閉廣告 mInterstitialVideoReq.removeListener(); } }); mInterstitialVideoReq.load();
透過mInterstitialVideoReq 與 onActivityResult()實做監聽影音廣告結束事件
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == 7522335) mInterstitialVideoReq.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data); }
並確保 AndroidManifest.xml 中具有下列宣告
//Interstitial <activity android:name="com.adlocus.VideoAdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:hardwareAccelerated="true" > </activity>