com.google.android.gms.ads.doubleclick.AppEventListener Java Examples
The following examples show how to use
com.google.android.gms.ads.doubleclick.AppEventListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DFPAppEventsFragment.java From android-ads with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); adView = getView().findViewById(R.id.appevents_av_main); adView.setAppEventListener(new AppEventListener() { @Override public void onAppEvent(String name, String data) { // The DFP ad that this fragment loads contains JavaScript code that sends App // Events to the host application. This AppEventListener receives those events, // and sets the background of the fragment to match the data that comes in. // The ad will send "red" when it loads, "blue" five seconds later, and "green" // if the user taps the ad. // This is just a demonstration, of course. Your apps can do much more interesting // things with App Events. if (name.equals("color")) { switch (data) { case "blue": rootView.setBackgroundColor(Color.rgb(0xD0, 0xD0, 0xFF)); break; case "red": rootView.setBackgroundColor(Color.rgb(0xFF, 0xD0, 0xD0)); break; case "green": rootView.setBackgroundColor(Color.rgb(0xD0, 0xFF, 0xD0)); break; } } } }); PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); adView.loadAd(adRequest); }
Example #2
Source File: DFPAppEventsFragment.java From googleads-mobile-android-examples with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); adView = getView().findViewById(R.id.appevents_av_main); adView.setAppEventListener(new AppEventListener() { @Override public void onAppEvent(String name, String data) { // The DFP ad that this fragment loads contains JavaScript code that sends App // Events to the host application. This AppEventListener receives those events, // and sets the background of the fragment to match the data that comes in. // The ad will send "red" when it loads, "blue" five seconds later, and "green" // if the user taps the ad. // This is just a demonstration, of course. Your apps can do much more interesting // things with App Events. if (name.equals("color")) { switch (data) { case "blue": rootView.setBackgroundColor(Color.rgb(0xD0, 0xD0, 0xFF)); break; case "red": rootView.setBackgroundColor(Color.rgb(0xFF, 0xD0, 0xD0)); break; case "green": rootView.setBackgroundColor(Color.rgb(0xD0, 0xFF, 0xD0)); break; } } } }); PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); adView.loadAd(adRequest); }