0
因此,如何在標題中說明如何從我的應用程序中移除admob插頁式廣告的代碼?這裏是包含插頁代碼的activity.java代碼,我想刪除它並添加一個不同的公司的廣告,恐怕我可能會搞砸一些東西,因爲我沒有編碼技能或經驗。如何從此代碼中移除admob的插頁式廣告
代碼Activity
:
package com.package.example;
import java.io.IOException;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.res.AssetFileDescriptor;
import android.util.Log;
import android.view.KeyEvent;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import com.google.analytics.tracking.android.EasyTracker;
import com.google.ads.*;
import com.google.ads.AdRequest.ErrorCode;
import com.kareem.Cairokee2014.R;
@SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface" })
public class activity extends Activity implements AdListener {
public MediaPlayer player = new MediaPlayer();
public WebView webView;
AssetFileDescriptor afd = null;
private InterstitialAd interstitial;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create the interstitial
interstitial = new InterstitialAd(this, "1234567890");
// Create ad request
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
interstitial.loadAd(adRequest);
// Set Ad Listener to use the callbacks below
interstitial.setAdListener(this);
this.webView = ((WebView)findViewById(R.id.webView));
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.setWebChromeClient(new WebChromeClient());
this.webView.addJavascriptInterface(this, "activity");
this.webView.loadUrl("file:///android_asset/index.html");
}
@Override
public void onReceiveAd(Ad ad) {
Log.d("OK", "Received ad");
if (ad == interstitial) {
interstitial.show();
}
}
@Override
public void onStart() {
super.onStart();
EasyTracker.getInstance().activityStart(this); // Add this method.
}
@Override
public void onStop() {
super.onStop();
EasyTracker.getInstance().activityStop(this); // Add this method.
}
int lastfile;
public void play(int n) {
if (lastfile != n && lastfile >= 1) {
player.stop();
player = new MediaPlayer();
}
lastfile = n;
try {
afd = getAssets().openFd("source/"+n+".mp3");
} catch (IOException e) {
e.printStackTrace();
}
try {
player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
player.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!player.isPlaying())
player.start();
}
public void pause() {
if (player.isPlaying())
player.pause();
}
public void stop() {
player.stop();
player = new MediaPlayer();
}
@Override
public void onDismissScreen(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
// TODO Auto-generated method stub
}
@Override
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN){
switch(keyCode)
{
case KeyEvent.KEYCODE_BACK:
if(webView.canGoBack() == true){
webView.goBack();
}else{
finish();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}
這裏是AndroidManifest
我找不到你說我應該刪除
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kareem.Cairokee2014"
android:versionCode="1"
android:versionName="1" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true">
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity
android:name="com.kareem.Cairokee2014.activity"
android:label="@string/app_name"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
刪除進口或Ctrl +在蝕移+ O。你還需要從清單中刪除一些東西 –
我在問題中添加了我的清單代碼,我沒有找到你在答案中的部分。也是什麼意思,「刪除導入」,如果我按Ctrl + Shift + o它刪除所有這些,但不是與應用程序關聯或只是插頁式廣告?我還想在應用中放置橫幅廣告,這樣做還是可以移除橫幅廣告?我認爲進口必須與分析和橫幅廣告相關。謝謝你的幫助! – Kareem
如果您仍在顯示其他廣告,您可能希望保留清單代碼。 –