New Update
❂ How to implement Facebook ads in android, i will guide you how to impenitent Facebook banner ad.
✺ To easily apply ads ✺
❂ please watch our YouTube video first..❂
❂ Gradle Scripts ✺
implementation 'com.facebook.android:audience-network-sdk:4.99.1'
❂ AndroidManifest.xml ✺
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:andwoid="http://schemas.android.com/apk/distribution"
package="com.rockbangla.hridoy.routersetuppage">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.rockbangla.hridoy.router_setup_page.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.ads.AudienceNetworkActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.rockbangla.hridoy.router_setup_page.Main2Activity"></activity>
</application>
</manifest>
❂ activity_main.xml ✺
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
...
>
...
<LinearLayout
android:id="@+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
/>
...
</RelativeLayout>
❂ MainActivity.java ✺
public class MainActivity extends AppCompatActivity {
AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adView = new AdView(this, getString(R.string.facebook_banner), AdSize.BANNER_HEIGHT_50);
LinearLayout adContainer = (LinearLayout) findViewById(R.id.banner_container);
adContainer.addView(adView);
adView.loadAd();
}
❂Please do not use this Advertising code❂
❂ Strings.xml ✺
<resources>
<string name="app_name">Router Setup Page</string>
<string name="facebook_banner">2166506726997545_2166509500330691</string>
<string name="user_login_data_are">User login data are:</string>
</resources>