我想adView
在我的应用程序中测试一些。因此,我将视图声明如下:
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="12345"
ads:loadAdOnCreate="true"
/>
我在我的片段中引用它:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.main_fragment, container,
false);
ListView lv = (ListView) rootView.findViewById(R.id.lv_frag_list);
final TelephonyManager tm = (TelephonyManager) getActivity()
.getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String deviceid = tm.getDeviceId();
AdRequest adReq = new AdRequest();
adReq.addTestDevice(deviceid);
AdView adview = (AdView) rootView.findViewById(R.id.ad);
adview.loadAd(adReq);
................................ //some code
return rootView;
}
保持空白,adView
我得到onFailedToReceiveAd
错误。我想这是因为我没有有效的 AdUnitId。我怎样才能让它用于测试目的?