TedAdHelper


Source link: https://github.com/ParkSangGwon/TedAdHelper

What is TedAdHelper?

English

Do you have your application?
Do you want make money using your application?
Then, you can add advertise in your application (banner, front ad, native ad, etc..)

If you want to know specific information, you can check this site.

And if you want use admob,facebook all, you need mediation
Admob and adlibr support mediation service.

But

They support mediation for only banner,front ad(don't support native ad mediation)
TedAdHelper support not only banner,front ad but also native ad, back press popup dialog
If you want show back press popup with advertise, you can use back press popup dialog.

Back Press Popup Dialog(with mediation)



Korean

TedAdHelper? ?? ????? ?? ????????.
Admob? Facebook Audience Network? ????? 2? ??? ??????? ?????.
adlibr?? Admob? ?? ????? ??? ?? ??? ??? ????? ?????? ???? Native??? ????? ? ? ????.
TedAdHelper??? Native Ad? ????? ?????.
(?? Native??? ??? ??????? ?? ??? ??????? ?? ???? ????.
??? ??? ?????? ???? ??? ?? ???? ???.)

??, ?? ???? ??? ?? ????? ????? ?? ??? ????.
??? ?? ??? ??? ??? ??? ?? Native ??? ????? ????? TedAdHelper? ?? ??????? ???? ??? ? ????.

???? ?? Dialog(with ?????)





Setup

Gradle

dependencies {

  compile 'gun0912.ted:tedadhelper:1.1.6' 
}
 



How to use

Test

For test advertise, you have to use test mode.
If you using live advertise, your advertise id will block from google/facebook.
So when you test your application, you load test Advertise(using your device ID).
Your device ID can be obtained by viewing the logcat output after creating a new ad.

Before loading advertise, set test device ID like this.

  • Facebook: TedAdHelper.setFacebookTestDeviceId("")
  • Admob: TedAdHelper.setAdmobTestDeviceId("")

Type

You can use 3 type advertise

If you use TNK factory's advertise, you have declare code in your AndroidManifest.xml

  • <meta-data android:name="tnkad_app_id" android:value=""/>

Banner

  1. Make banner container in xml
 <FrameLayout

android:id="@+id/bannerContainer"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

/>

  1. Show banner using TedAdBanner
TedAdBanner.showBanner(ViewGroup bannerContainer, String facebookKey, String admobKey, int adPriority, OnBannerAdListener onBannerAdListener) 
  • adPriority: TedAdHelper.AD_FACEBOOK / TedAdHelper.AD_ADMOB

  /** 

* Banner 

*/

 FrameLayout bannerContainer = (FrameLayout) findViewById(R.id.bannerContainer);

 //TedAdBanner.showFacebookBanner();


//TedAdBanner.showAdmobBanner();


 TedAdBanner.showBanner(bannerContainer, FACEBOOK_KEY_BANNER, ADMOB_KEY_BANNER, TedAdHelper.AD_FACEBOOK, new OnBannerAdListener() {

 @Override

 public void onError(String errorMessage) {

  
}

  @Override

 public void onLoaded(int adType) {

  
}

  @Override

 public void onAdClicked(int adType) {

  
}

  @Override

 public void onFacebookAdCreated(com.facebook.ads.AdView facebookBanner) {

 
}

 
}
);
 





Front AD

TedAdFront.showFrontAD(Context context, String facebookKey, final String admobKey, Integer[] adPriorityList, OnFrontAdListener onFrontAdListener)
  • adPriorityList: TedAdHelper.AD_FACEBOOK / TedAdHelper.AD_ADMOB / TedAdHelper.AD_TNK

  /** 

* Front AD 

*/

 //TedAdFront.showAdmobFrontAd();


//TedAdFront.showFacebookFrontAd();


TedAdFront.showFrontAD(this, FACEBOOK_KEY_FRONT, ADMOB_KEY_FRONT, new Integer[]{
TedAdHelper.AD_ADMOB,TedAdHelper.AD_FACEBOOK,TedAdHelper.AD_TNK
}
, new OnFrontAdListener() {

 @Override

 public void onDismissed(int adType) {

  
}

  @Override

 public void onError(String errorMessage) {

  
}

  @Override

 public void onLoaded(int adType) {

  
}

  @Override

 public void onAdClicked(int adType) {

  
}

  @Override

 public void onFacebookAdCreated(InterstitialAd facebookFrontAD) {

 
}

}
);
 





BackPress Popup Dialog

TedBackPressDialog.startDialog(Activity activity, String appName, String facebookKey, String admobKey, Integer[] adPriorityList, boolean showReviewButton,OnBackPressListener onBackPressListener)
  • adPriorityList: TedAdHelper.AD_FACEBOOK / TedAdHelper.AD_ADMOB / TedAdHelper.AD_TNK
  • If you use Glide 4.x version, you have to make your image provider new TedAdHelper.ImageProvider(). You can check this function in sample project
 @Override
  public void onBackPressed() {

 //TedBackPressDialog.startFacebookDialog();


//TedBackPressDialog.startAdmobDialog();


TedBackPressDialog.startDialog(this, getString(R.string.app_name), FACEBOOK_KEY_BACKPRESS, ADMOB_KEY_BACKPRESS, TedAdHelper.AD_FACEBOOK, new OnBackPressListener() {

 @Override

 public void onReviewClick() {

 
}

  @Override

 public void onFinish() {

  finish();

 
}

  @Override

 public void onError(String errorMessage) {

 
}

  @Override

 public void onLoaded(int adType) {

 
}

  @Override

 public void onAdClicked(int adType) {

 
}

}
);

  
}
 





Native AD

  1. Make your Native ad container and include adview_native_base.xml
 <android.support.v7.widget.CardView

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/cardview"

android:layout_width="match_parent"

android:layout_height="wrap_content"

 app:cardBackgroundColor="@color/white"

app:cardCornerRadius="2dp"

app:cardElevation="5dp"

app:cardUseCompatPadding="true">

 <include layout="@layout/adview_native_base"/>

</android.support.v7.widget.CardView>
  1. Make instance and Show Native ad using TedNativeAdHolder

  View cardview = findViewById(R.id.cardview);

TedNativeAdHolder tedNativeAdHolder = new TedNativeAdHolder(cardview, this, getString(R.string.app_name), FACEBOOK_KEY_NATIVE, ADMOB_KEY_NATIVE);

 tedNativeAdHolder.loadAD(new Integer[]{
TedAdHelper.AD_FACEBOOK,TedAdHelper.AD_ADMOB
}
, new OnNativeAdListener() {

 @Override

 public void onError(String errorMessage) {

  
}

  @Override

 public void onLoaded(int adType) {

  
}

  @Override

 public void onAdClicked(int adType) {

  
}

}
);

//tedNativeAdHolder.loadFacebookAD();


//tedNativeAdHolder.loadAdmobAD();
 
  • If you use Glide 4.x version, you have to make your image provider new TedAdHelper.ImageProvider(). You can check this function in sample project





Customize

Color

You can change button or divider color. Override variable in your colors.xml

 <color name="tedBtnPrimary">...</color>
  <color name="tedBtnHighlight">...</color>

Check Facebook app

If you want request facebook advertise for only facebook app installed user, you can use showAdOnlyFacebookInstalledUser(). Library check facebook app installed or not.

TedAdHelper.showAdOnlyFacebookInstalledUser(true);





FAQ

1. I got error message leaked IntentReceiver com.facebook.ads.internal.DisplayAdController$c@cf9db8c that was originally registered here. Are you missing a call to unregisterReceiver()?

If you use Facebook Audience Network, you have to destroy your banner or front ad

 @Override
  protected void onDestroy() {

 if (facebookFrontAD != null) {

 facebookFrontAD.destroy();

}

 if (facebookBanner != null) {

 facebookBanner.destroy();

}

 super.onDestroy();

  
}
 

You can get facebookFrontAD, facebookBanner instance from onFacebookAdCreated(InterstitialAd facebookFrontAD) method

  TedAdFront.showFrontAD(this, FACEBOOK_KEY_FRONT, ADMOB_KEY_FRONT, TedAdHelper.AD_ADMOB, new OnFrontAdListener() {

...

  @Override

 public void onFacebookAdCreated(InterstitialAd facebookFrontAD) {

  MainActivity.this.facebookFrontAD = facebookFrontAD;

 
}

}
);



2. I want change native ad layout

If you want customize your native ad, you have to overwrite view id.
Make your layout (not include <include layout="@layout/adview_native_base"/> code)
You have to declare view id

  • R.id.view_root (RelativeLayout): If Native ad load fail, this view will disappear
  • R.id.container_admob_express (container_admob_express): For add admobExpress
  • R.id.progressView (ProgressBar): When advertise loading, this view will appear
  • R.id.view_container (LinearLayout): when advertise loaded, this view will appear
  • R.id.iv_logo (ImageView)
  • R.id.tv_name (TextView)
  • R.id.native_ad_media (com.facebook.ads.MediaView)
  • R.id.iv_image (ImageView)
  • R.id.tv_body (TextView)
  • R.id.tv_call_to_action (TextView)
  • R.id.tv_etc (TextView)



License

Copyright 2017 Ted Park  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.```  

Resources

A simple asynchronous RSS 2.0 reader library for Android.

An extension for Google's AutoValue that omits @Redacted field values from toString().

A collection of source code generators for Java.

Subprojects:

  • AutoFactory - JSR-330-compatible factories
  • AutoService - Provider-configuration files for ServiceLoader
  • AutoValue - Immutable value-type code generation for Java 1.6+.
  • Common - Helper utilities for writing annotation processors.

CAT

A logging library for Android with focus on convenient usage and extensibility.

A download button with pretty cool animation.

Want to assert that class has private constructor? Let's do it!

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes