如何防止Android应用中的广告

时间:2015-12-03 04:32:40

标签: android admob adblock

我第一次在我的Android应用程序中使用广告拦截器。这是我的代码。

    p

ublic class Myapp extends Activity {

    LinearLayout linearlayout;

    public Myapp(Activity activity, AdSize adSize, String adUnitId) {
        // TODO Auto-generated constructor stub

        setContentView(R.layout.addmob);
     linearlayout=(LinearLayout)findViewById(R.id.linear_admo);
        hideAd();

    }



    public Myapp() {


    }


    private void hideAd() {
        final AdView adLayout = (AdView) findViewById(R.id.adView);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                adLayout.setEnabled(false);
                adLayout.setVisibility(View.GONE);
            }
        });
    }



}

public class MyAdView extends com.app.Myapp{

Myapp myapp=new Myapp();

    public MyAdView(Activity activity, AdSize adSize, String adUnitId)
    {
         super(activity, adSize, adUnitId);


    }
}



This is Xml part in my android application.Which have i used adView.but latterly i confused how to implement ad blocker in android application. 

<?xml version="1.0" encoding="utf-8"?>
<Linear-layout xmlns:android="HTTP://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:id="@+id/linear_admo"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.App.My-app android:id="@+id/ad-view"
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             ads:adUnitId="0"
                             ads:adSize="BANNER"
                             android:layout_margin="5dp"
                             ads:loadAdOnCreate="false"/>


</Linear-layout>

give some idea to prevent unwanted ad coming in android application.that irritate when user open application and interrupt application working.so i want to implement ad-blocker working in my application.This is very important section in my android application.i am new in android application development and most in the ad-blocker part in development.

0 个答案:

没有答案