本文整理匯總了Java中com.google.android.gms.ads.AdView.loadAd方法的典型用法代碼示例。如果您正苦於以下問題:Java AdView.loadAd方法的具體用法?Java AdView.loadAd怎麽用?Java AdView.loadAd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.ads.AdView
的用法示例。
在下文中一共展示了AdView.loadAd方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_main, container, false);
AdView mAdView = (AdView) root.findViewById(R.id.adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device. e.g.
// "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device."
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
return root;
}
示例2: onCreate
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(getApplicationContext(), "YOUR UNIT ID");
AdView adView = (AdView) this.findViewById(R.id.adMob);
//request TEST ads to avoid being disabled for clicking your own ads
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)// This is for emulators
//test mode on DEVICE (this example code must be replaced with your device uniquq ID)
// .addTestDevice("2EAB96D84FE62876379A9C030AA6A0AC") // Nexus 5
.build();
adView.loadAd(adRequest);
}
示例3: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_quiz2, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)v.findViewById(R.id.adViewques2);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return v;
}
示例4: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz4, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques4);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例5: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz12, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques12);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例6: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.more_info_fragment, container, false);
ButterKnife.bind(this, mView);
auth.getCurrentUser();
Uri photoUrl = auth.getCurrentUser().getPhotoUrl();
Glide.with(this).load(photoUrl).into(imageView);
String strMeatFormat = getResources().getString(R.string.welcome_format);
String strMeatMsg = String.format(strMeatFormat, auth.getCurrentUser().getDisplayName());
mProfileName.setText(strMeatMsg);
adView = (AdView) mView.findViewById(R.id.adView);
AdRequest builder = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
adView.loadAd(builder);
return mView;
}
示例7: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz15, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques15);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例8: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz5, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques5);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例9: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz9, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques9);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例10: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz11, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques11);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例11: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz13, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques13);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例12: onCreate
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidThreeTen.init(this);
start_date = LocalDate.now();
end_date = LocalDate.now();
seed = DEFAULT_SEED;
setContentView(R.layout.activity_main);
// Load an ad into the AdMob banner view.
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().setRequestAgent("android_studio:ad_template").build();
adView.loadAd(adRequest);
potd_list_view = (ListView) findViewById(R.id.potd_list);
generate_potd_list();
}
示例13: showGoogleAdMobAds
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
private void showGoogleAdMobAds(Activity activity) {
try {
AdView adView = new AdView(activity);
adView.setAdUnitId("ca-app-pub-5619114666968507/6860732934");
adView.setAdSize(AdSize.BANNER);
LinearLayout layout = (LinearLayout) activity.findViewById(R.id.adsLayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request.
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(TESTDEVICE_SGS5)
.addTestDevice(TESTDEVICE_SGS3MINI)
.addTestDevice(TESTDEVICE_DUOS_Y).build();
// Load the adView with the ad request.
adView.loadAd(adRequest);
} catch (Exception e) {
Log.e(TAG, "Error while getting ads", e);
}
}
示例14: onCreate
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState)
{
// Log.e("oncreate", "a");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sliding_station);
setGlobalDisplay();
setViewPagerConfig(savedInstanceState);
setUpdateConfig();
adView = (AdView) this.findViewById(R.id.adView1);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(
"9F95B44EAECFE486860F1D1FAB856B0E").build();
adView.loadAd(adRequest);
}
示例15: onCreate
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
AppData.context = this;
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.menu_pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setOffscreenPageLimit(1);
mViewPager.setCurrentItem(1);
searchLinesFragment = new SearchLinesFragment();
favoritesFragment = new FavoritesFragment();
searchStationsFragment = new SearchStationsFragment();
adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(
"9F95B44EAECFE486860F1D1FAB856B0E").build();
adView.loadAd(adRequest);
}