AdMob z usług Google Play wykona niepożądane automatyczne przewijanie
Korzystałem z AdMob z usług Google Play w wersji 13. Zdaję sobie sprawę, kiedy umieszczam reklamę w środkuScrollView
, AdMob spróbuje wykonać niepożądane automatyczne przewijanie, po pomyślnym pobraniu reklamy z serwera.
package com.example.admob_bug;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create the adView.
adView = new AdView(this);
adView.setAdUnitId("a151b03485063e0");
adView.setAdSize(AdSize.BANNER);
// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout".
LinearLayout layout = (LinearLayout)findViewById(R.id.advertisement);
// Add the adView to it.
layout.addView(adView);
// Initiate a generic request.
AdRequest adRequest = new AdRequest.Builder().build();
// Load the adView with the ad request.
adView.loadAd(adRequest);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onPause() {
adView.pause();
super.onPause();
}
@Override
public void onResume() {
super.onResume();
adView.resume();
}
@Override
public void onDestroy() {
adView.destroy();
super.onDestroy();
}
private AdView adView;
}
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
...
...
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text 7"
android:layout_margin="30dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:id="@+id/advertisement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text 8"
android:layout_margin="30dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</ScrollView>
Pełny kod źródłowy można pobrać zhttps://www.dropbox.com/s/e53zjqsc5cnilz2/admob_bug.zip
Zrozumiesz ten problem po odczekaniu około 10 sekund (w zależności od jakości sieci) po załadowaniu reklamy.
Czy jest jakieś obejście zapobiegające automatycznemu przewijaniu?
Problemu tego nie było, zanim przełączyłem się ze starego AdMob 6.4.1 JAR na AdMob z Google Play.
Testuję za pomocą urządzenia Nexus S, Android 4.1.2.