How can I set meta-data AdMob app ID using Java | How To Change Admob AppID Using Firebase | AdMob app ID using Admin panel in Android studio

 

How can I set meta-data AdMob app ID using Java | AdMob app ID using Admin panel in Android studio
How can I set meta-data AdMob app ID using Java | How To Change Admob AppID Using Firebase | AdMob app ID using Admin panel in Android studio


How can I set meta-data AdMob app ID using Java | How To Change Admob AppID Using Firebase | AdMob app ID using Admin panel in Android studio

How can I set meta-data AdMob app ID using Java.

How To Change Admob AppID Using Firebase. 

AdMob app ID using Admin panel in Android studio.


Code Example: 

    implementation 'com.google.firebase:firebase-database:19.6.0'
implementation 'com.google.firebase:firebase-core:18.0.0'
implementation 'com.firebase:firebase-client-android:2.5.1'
/////////

appId("https://winapp-98d0e-default-rtdb.firebaseio.com/urle");

/////////

private void appId(String url){
Firebase.setAndroidContext(this);
Firebase firebase = new Firebase(url);
firebase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
JSON_BASE_URL = dataSnapshot.getValue(String.class);
Button.setText(JSON_BASE_URL);
}

@Override
public void onCancelled(FirebaseError firebaseError) {

}
});

}


/////////

try {

ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String myApiKey = bundle.getString("com.google.android.gms.ads.APPLICATION_ID");

ai.metaData.putString("com.google.android.gms.ads.APPLICATION_ID", adUnitId);//you can replace your key APPLICATION_ID here
String ApiKey = bundle.getString("com.google.android.gms.ads.APPLICATION_ID");

unit.setText(ApiKey);



} catch (PackageManager.NameNotFoundException e) {

} catch (NullPointerException e) {

}


Code Example Link: 
https://stackoverflow.com/questions/59788825/how-can-i-set-adunitid-using-java/66451809#66451809


Video Link:  https://drive.google.com/drive/folders/1zJEp9gJW0d-Hdtgketv_iPBvL2Q2VNAy

Code Example XML: 

https://stackoverflow.com/questions/59788825/how-can-i-set-adunitid-using-java/66451809#66451809
////// XML
<LinearLayout
android:id="@+id/layout_banner_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#838383"
android:orientation="vertical"
android:visibility="visible"></LinearLayout>

////// JAVA

LinearLayout adBannerLayout = (LinearLayout) findViewById(R.id.layout_banner_holder);

AdView adView = new AdView(this);
adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
adView.setAdSize(AdSize.SMART_BANNER);
adBannerLayout.addView(adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);



HOME