Android个人开发者接广告admob以及需要注意的错误细节,Android用adb命令打开开发者模式
比如 private void displayAppInstallAd(ViewGroup parent,NativeAppInstallAd ad) { // Inflate a layout and add it to the parent ViewGroup. LayoutInflater inflater = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); NativeAppInstallAdView adView = (NativeAppInstallAdView) inflater .inflate(R.layout.my_ad_layout, parent); // Locate the view that will hold the headline, set its text, and call the // NativeAppInstallAdViews setHeadlineView method to register it. TextView headlineView = adView.findViewById(R.id.ad_headline); headlineView.setText(ad.getHeadline()); adView.setHeadlineView(headlineView); // Repeat the above process for the other assets in the NativeAppInstallAd // If the app is using a MediaView to display video, it should be // instantiated and passed to setMediaView. This view is a little different // in that the asset is populated automatically, so theres one less step. MediaView mediaView = (MediaView) adView.findViewById(R.id.ad_media); adView.setMediaView(mediaView); // Call the NativeAppInstallAdViews setNativeAd method to register the // NativeAdObject. adView.setNativeAd(ad); // Place the AdView into the parent. parent.addView(adView); }这里需要传递一个参数,文档并没有说是怎么出来的,我感觉需要找找他们的demo.https://developers.google.com/admob/Android/nativeadvanced?hl=zhCNhttps://apps.admob.com/v2/home将 Firebase 添加到您的 Android 项目https://firebase.google.com/docs/Android/setupbuildscript { // ... dependencies { // ... classpath com.google.gms:googleservices:3.2.0 // googleservices plugin }}allprojects { // ... repositories { // ... maven { url https://maven.google.com // Googles Maven repository } }}完整步骤1.请使用此应用 ID 完成说明:2.请集成 SDK。