Android Question FirebaseAdMob

Discussion in 'Android Questions' started by dibesw, Aug 1, 2019.

  1. dibesw

    dibesw Active Member Licensed User

    In this code
    Code:
    Sub LoadAd
        BannerAd.Initialize2(
    "BannerAd""ca-app-pub-9301XXXXXXXX5507~3463805004", BannerAd.SIZE_SMART_BANNER)
        
    Dim height As Int
       
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
        
    'phones
        If 100%x > 100%y Then height = 32dip Else height = 50dip
       
    Else
        
    'tablets
        height = 90dip
       
    End If
       
    Activity.AddView(BannerAd, 0dip100%y - height, 100%x, height)
       BannerAd.LoadAd
    End Sub
    which is the ID that need insert into AD UNIT ID?

    A or B
    and if A, must to be insert char "~" o "/"?

    [​IMG]

    [​IMG]


    Thanks
     
    Last edited: Aug 6, 2019
  2. asales

    asales Well-Known Member Licensed User

  3. sorex

    sorex Expert Licensed User

    placement id is B
     
  4. dibesw

    dibesw Active Member Licensed User

    Ok ASALES, SOREX
    Code:
    Sub BannerAd_FailedToReceiveAd (ErrorCode As String)
        
    ToastMessageShow("failed: " & ErrorCode,False)
    End Sub
    I take ErrorCode=3 and the banner is not issued

    1) My application in FireBase is connected to AdMob
    2) The ultimate google-services.json is in appdir
    3) account payments is OK (in AD unit)
    4) B4A 9.30
    5) My app run to android 8.0
    6) My account is ready (email from admob)
    7) Manifest is:
    Code:
    'This code will be applied to the manifest file during compilation.
    'You do not need to modify it in most cases.
    'See this link for for more information: http://www.basic4ppc.com/forum/showthread.php?p=78136
    AddManifestText(
    <uses-sdk android:minSdkVersion=
    "14" android:targetSdkVersion="28"/>
    <supports-screens android:largeScreens=
    "true"
        android:normalScreens=
    "true"
        android:smallScreens=
    "true"
        android:anyDensity=
    "true"/>)
    SetApplicationAttribute(android:icon, 
    "@drawable/icon")
    SetApplicationAttribute(android:
    label"$LABEL$")
    'End of default text.
    AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)
    AddManifestText(<uses-feature android:name=
    "android.hardware.location.gps"/>)
    AddApplicationText(<meta-data
        android:name=
    "com.google.android.gms.version"
        android:value=
    "@integer/google_play_services_version" />)
    AddPermission(android.permission.READ_PHONE_STATE)
    AddPermission(android.permission.CALL_PHONE)
    AddPermission(android.permission.ACCESS_COARSE_LOCATION)
    CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
    CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
    CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
    CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
    CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
    CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
    '************ Firebase Ads ************
    AddApplicationText(
      <
    activity
      android:name=
    "com.google.android.gms.ads.AdActivity"
      android:configChanges=
    "keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
      android:theme=
    "@android:style/Theme.Translucent" />
      <
    activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
      android:theme=
    "@style/Theme.IAPTheme"/>
    )
    '************ Firebase Ads (end) ************
    '************ Firebase Base ************
    CreateResourceFromFile("google-services""google-services.json")
    AddPermission(android.permission.ACCESS_NETWORK_STATE)
    AddPermission(android.permission.INTERNET)
    AddPermission(android.permission.WAKE_LOCK)
    AddPermission(com.google.android.c2dm.permission.RECEIVE)
    AddPermission(${applicationId
    }.permission.C2D_MESSAGE)
    AddPermission(com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE)
    AddManifestText( <permission android:name="$
    {applicationId}.permission.C2D_MESSAGE"
      android:protectionLevel="signature" />)
    AddApplicationText(
     <receiver
                android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
                android:enabled="true"
                android:exported="false" >
            </receiver>

      <service
                android:name="com.google.android.gms.measurement.AppMeasurementService"
                android:enabled="true"
                android:exported="false" />
            
     <receiver
                android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
                android:enabled="true"
                android:exported="true"
                android:permission="android.permission.INSTALL_PACKAGES" >
                <intent-filter>
                    <action android:name="com.android.vending.INSTALL_REFERRER" />
                </intent-filter>
    </receiver>
    <service
                android:name="com.google.android.gms.measurement.AppMeasurementJobService"
                android:enabled="true"
                android:exported="false"
                android:permission="android.permission.BIND_JOB_SERVICE" />

     <service android:name="com.google.firebase.components.ComponentDiscoveryService" >
                <meta-data
                    android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
                    android:value="com.google.firebase.components.ComponentRegistrar" />
                <meta-data
                    android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
                    android:value="com.google.firebase.components.ComponentRegistrar" />
                 <meta-data
                    android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
                    android:value="com.google.firebase.components.ComponentRegistrar" />
    </service>
       <provider
      android:authorities="$
    {applicationId}.firebaseinitprovider"
      android:name="com.google.firebase.provider.FirebaseInitProvider"
      android:exported="false"
      android:initOrder="100" />
     
       <receiver
      android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
      android:exported="true"
      android:permission="com.google.android.c2dm.permission.SEND" >
      <intent-filter>
      <action android:name="com.google.android.c2dm.intent.RECEIVE" />
      <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
      <category android:name="$
    {applicationId}" />
      </intent-filter>
      </receiver>
        <receiver
      android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
      android:exported="false" />


      <service
      android:name="com.google.firebase.iid.FirebaseInstanceIdService"
      android:exported="true">
      <intent-filter android:priority="-500">
      <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
      </intent-filter>
      </service>
    )

    '************ Firebase Base (end) ************
    ASALES,SOREX or someone else can help me?

    Thanks in advance
     
  5. asales

    asales Well-Known Member Licensed User

  6. dibesw

    dibesw Active Member Licensed User

    I do not know what happened
    I tried to test ID and it worked
    After I have taken out test ID and it worked the same!!o_O
    (after so many times I tried) :(
    Code for test is
    Code:
    Sub LoadAd
        BannerAd.Initialize2(
    "BannerAd""ca-app-pub-9301620xxxxxxxxxx/8543266512", BannerAd.SIZE_SMART_BANNER)
        BannerAd.LoadAdWithTestDevice(
    "CAD8007B065E0B86EF3C52DFD5558E21")
        
    Dim height As Int
       
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
        
    'phones
        If 100%x > 100%y Then height = 32dip Else height = 50dip
       
    Else
        
    'tablets
        height = 90dip
       
    End If
       
    Activity.AddView(BannerAd, 0dip100%y - height, 100%x, height)
        
    'Activity.AddView(BannerAd, 0, 0,  320dip, 50dip)
       'BannerAd.LoadAd
    End Sub
    I hope it serves somebody;)
     
    Last edited: Aug 7, 2019
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice