0
ユーザーがadviewをクリックした後に広告の読み込みを停止したいのですが、既にadlistenerを実装していて、adView.stopLoading(); onDismissScreenに、私は、広告のWebページを閉じたとき、私は次のエラーを取得する:クリック後にadmob広告の読み込みを停止します
E/AndroidRuntime(1059): java.lang.RuntimeException: Unable to pause activity {ivn.com.teletextinternational/com.google.ads.AdActivity}: java.lang.NullPointerException
コード:
public class MyActivity extends Activity implements OnClickListener, AdListener {
RelativeLayout relativeLayout1;
ImageView imgpag;
FrameLayout frameLayout1;
FrameLayout frameLayout2;
Button right;
Button left;
ProgressBar probar;
LinearLayout linear;
AdView adView;
EditText numbox;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imgpag = (ImageView)findViewById (R.id.imgpag);
relativeLayout1 = (RelativeLayout) findViewById(R.id.RelativeLayout1);
frameLayout1 = (FrameLayout) findViewById(R.id.frameLayout1);
frameLayout2 = (FrameLayout) findViewById(R.id.frameLayout2);
left = (Button) findViewById(R.id.left);
right = (Button) findViewById(R.id.right);
probar = (ProgressBar) findViewById (R.id.probar);
adView = new AdView(this, AdSize.BANNER, "a14ebbcd3aae1ff");
LinearLayout linear = (LinearLayout) findViewById (R.id.linear);
linear.addView(adView);
adView.loadAd(new AdRequest());
adView.setAdListener(this);
}
public void onDismissScreen(Ad arg0) {
adView.stopLoading();
linear.setVisibility(View.GONE);//if you want hide ads
}
}
は動作しませんが、エラーは表示されませんが、広告の読み込み中に何も起こりません。 また、linear.removeView(adView)を追加すると、前と同じエラーが返されます – user1001635
広告がもう更新されないようにしても、表示させたいユースケースはありますか? stopLoadingは既にそのプロセスを開始している場合は広告の読み込みを停止しますが、stopLoadingはインタースティシャル広告の方が便利だと思います。 'linear'エラーに関しては、線形フィールドを初期化するのではなく、ローカル線形オブジェクトを定義するのと同じ間違いをしています。 –
は現在動作しています:) thks eric – user1001635