@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); linearLayout = (LinearLayout) findViewById(R.id.linearLayout); adView_1 = new AdView(this); adView_1.setAdUnitId("ca-app-pub-2538596252160048/1329783818"); adView_1.setAdSize(AdSize.BANNER); linearLayout.addView(adView_1); adView_2 = new AdView(this); adView_2.setAdUnitId("ca-app-pub-2538596252160048/1329783818"); adView_2.setAdSize(AdSize.MEDIUM_RECTANGLE); linearLayout.addView(adView_2); interstitial = new InterstitialAd(this); interstitial.setAdUnitId("ca-app-pub-2538596252160048/1329783818"); AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("AF8CDE91144F6A31C28629FD2573AB82") .build(); adView_1.setAdListener( new AdListener() { @Override public void onAdLoaded() { Log.i("Script", "onAdLoaded()"); } @Override public void onAdFailedToLoad(int error) { Log.i("Script", "onAdFailedToLoad(" + error + ")"); } @Override public void onAdOpened() { Log.i("Script", "onAdOpened()"); } @Override public void onAdClosed() { Log.i("Script", "onAdClosed()"); } @Override public void onAdLeftApplication() { Log.i("Script", "onAdLeftApplication()"); } }); adView_1.loadAd(adRequest); adView_2.loadAd(adRequest); interstitial.loadAd(adRequest); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); adView = new AdView(this); adView.setAdUnitId("ca-app-pub-9480879598480702/4025467071"); adView.setAdSize(AdSize.SMART_BANNER); RelativeLayout rl = new RelativeLayout(this); RelativeLayout.LayoutParams lay = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lay.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); com.google.android.gms.ads.AdRequest adRequest = new com.google.android.gms.ads.AdRequest.Builder() .addTestDevice("13F77AAABEE7FB57CF4FA6BD90138B61") .build(); panel = new MainGamePanel(this, adView); rl.addView(panel); rl.addView(adView, lay); // Carregar o adView com a solicitação de anúncio. adView.loadAd(adRequest); setContentView(rl); // setContentView(panel); }
private void _initAdView() { try { mViewAdv = findViewById(R.id.mViewAdv); // get value form task manager Container container = LazzyBeeSingleton.getContainerHolder().getContainer(); String admob_pub_id = null; String adv_id = null; if (container == null) { } else { admob_pub_id = container.getString(LazzyBeeShare.ADMOB_PUB_ID); adv_id = container.getString(LazzyBeeShare.ADV_DETAILS_ID); Log.i(TAG, "admob -admob_pub_id:" + admob_pub_id); Log.i(TAG, "admob -adv_id:" + adv_id); } if (admob_pub_id != null) { if (adv_id == null || adv_id.equals(LazzyBeeShare.EMPTY)) { mViewAdv.setVisibility(View.GONE); } else if (adv_id != null || adv_id.length() > 1 || !adv_id.equals(LazzyBeeShare.EMPTY) || !adv_id.isEmpty()) { String advId = admob_pub_id + "/" + adv_id; Log.i(TAG, "admob -AdUnitId:" + advId); AdView mAdView = new AdView(this); mAdView.setAdSize(AdSize.BANNER); mAdView.setAdUnitId(advId); AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice(getResources().getStringArray(R.array.devices)[0]) .addTestDevice(getResources().getStringArray(R.array.devices)[1]) .addTestDevice(getResources().getStringArray(R.array.devices)[2]) .addTestDevice(getResources().getStringArray(R.array.devices)[3]) .build(); mAdView.loadAd(adRequest); RelativeLayout relativeLayout = ((RelativeLayout) findViewById(R.id.adView)); RelativeLayout.LayoutParams adViewCenter = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); adViewCenter.addRule(RelativeLayout.CENTER_IN_PARENT); relativeLayout.addView(mAdView, adViewCenter); mViewAdv.setVisibility(View.VISIBLE); } else { mViewAdv.setVisibility(View.GONE); } } else { mViewAdv.setVisibility(View.GONE); } } catch (Exception e) { LazzyBeeShare.showErrorOccurred(context, "_initAdView", e); } }
private void addAd() { // Create the adView AdView adView = new AdView(this); adView.setAdSize(AdSize.SMART_BANNER); adView.setAdUnitId(getString(R.string.banner_ad_unit_id)); ((ViewGroup) findViewById(android.R.id.list).getParent().getParent().getParent()) .addView(adView, 0); // Initiate a generic request to load it with an ad adView.loadAd( new AdRequest.Builder().addTestDevice("5B5C0102B231DC20553952DAC00561A6").build()); }
private void initAdView() { LinearLayout layout = (LinearLayout) findViewById(R.id.layout); mAdview = new AdView(this); mAdview.setAdUnitId(ADID); mAdview.setAdSize(AdSize.BANNER); layout.addView(mAdview); // Initiate a generic request. AdRequest adRequest = new AdRequest.Builder().build(); // Load the adView with the ad request. mAdview.loadAd(adRequest); }
private void _initAdMob() { FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; LayoutInflater inflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflate.inflate(R.layout.admob, null); addContentView(view, params); adViewLayout = (FrameLayout) view.findViewById(R.id.admob); // Create an ad. adView = new AdView(this); adView.setAdSize(AdSize.BANNER); adView.setAdUnitId(getResources().getString(R.string.AD_UNIT_ID)); adView.setLayoutParams(params); // Add the AdView to the view hierarchy. The view will have no size // until the ad is loaded. adViewLayout.addView(adView); // Create an ad request. Check logcat output for the hashed // device ID to // get test ads on a physical device. AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE") .build(); // Start loading the ad in the background. adView.loadAd(adRequest); adViewLayout.setBackgroundColor(Color.BLACK); adViewLayout.setBackgroundColor(0); showAd(); }
private void createAdView() { // Create and plate the Banner Ad in activity_main.xml adView = new AdView(this); adView.setAdUnitId("ca-app-pub-1314947069846070/4608411941"); adView.setAdSize(AdSize.BANNER); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); adView.setLayoutParams(params); RelativeLayout background = (RelativeLayout) findViewById(R.id.activity_main); background.addView(adView); // Request for Ads AdRequest adRequest = new AdRequest.Builder().addTestDevice("FFAA2B4ECD49CBF2A0AB7F9D447410D7").build(); // Load ad request into Adview adView.loadAd(adRequest); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); com.google.android.gms.ads.AdView adView = new com.google.android.gms.ads.AdView(MapActivity.this); adView.setAdUnitId("ca-app-pub-1878227272753934/2393548800"); adView.setAdSize(AdSize.BANNER); RelativeLayout layout = (RelativeLayout) findViewById(R.id.addshows); layout.addView(adView); layout.setGravity(Gravity.CENTER); com.google.android.gms.ads.AdRequest request = new com.google.android.gms.ads.AdRequest.Builder().build(); adView.loadAd(request); Bundle extras = getIntent().getExtras(); if (extras != null) { lat = extras.getDouble("latitude"); lon = extras.getDouble("longitude"); } btn_search = (Button) findViewById(R.id.button_search); btn_search.setOnClickListener(this); spinner_items = (Spinner) findViewById(R.id.spinner_items); mPlaceType = getResources().getStringArray(R.array.place_type); mPlaceTypeName = getResources().getStringArray(R.array.place_type_name); ArrayAdapter<String> adapter = new ArrayAdapter<String>( this, android.R.layout.simple_spinner_dropdown_item, mPlaceTypeName); spinner_items.setAdapter(adapter); try { // Loading map initilizeMap(); // Changing map type googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); // googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); // googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); // googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); // googleMap.setMapType(GoogleMap.MAP_TYPE_NONE); // Showing / hiding your current location googleMap.setMyLocationEnabled(true); // Enable / Disable zooming controls googleMap.getUiSettings().setZoomControlsEnabled(false); // Enable / Disable my location button googleMap.getUiSettings().setMyLocationButtonEnabled(true); // Enable / Disable Compass icon googleMap.getUiSettings().setCompassEnabled(true); // Enable / Disable Rotate gesture googleMap.getUiSettings().setRotateGesturesEnabled(true); // Enable / Disable zooming functionality googleMap.getUiSettings().setZoomGesturesEnabled(true); double[] randomLocation = createRandLocation(lat, lon); CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(lat, lon)).zoom(15).build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } catch (Exception e) { e.printStackTrace(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setBehindContentView(R.layout.activity_menu); getSlidingMenu().setBehindOffset(100); getSlidingMenu().setShadowDrawable(R.drawable.shadow); getSlidingMenu().setShadowWidth((int) 10f); preferenceHelper = new PreferenceHelper(MainActivity.this); mCurrent = 0; db = new MySQLiteHelper(MainActivity.this); addDataMenu(); // mHandler.post(rLong); // mHandler.post(rShort); // mHandler.post(rVideo); thr = new Thread( new Runnable() { @Override public void run() { getArticle(); getShort(); getVideo(); } }); sendDeviceId(); thr.start(); btnback = (ImageButton) findViewById(R.id.btn_back); progressBar = (ProgressBar) findViewById(R.id.progressBar1); btnRefresh = (ImageButton) findViewById(R.id.btn_refresh); listMenu = (ListView) findViewById(R.id.list_menu); adapter = new MenuAdapter(MainActivity.this, menuItems); listMenu.setAdapter(adapter); frag = new Home(); replaceFragment(frag); listMenu.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) { mCurrent = position; adapter.notifyDataSetChanged(); switch (position) { case 0: toggle(); pos = 0; frag = new Home(); break; case 1: toggle(); pos = 1; frag = new LongPost(); break; case 2: toggle(); pos = 2; frag = new ShortPost(); break; case 3: toggle(); pos = 3; frag = new VideoPost(); break; } if (frag != null) { replaceFragment(frag); } else { } } }); init(); // intersials // Create the interstitial. // initAd(); initAdBanner(); // Create an ad. adView = new AdView(this); adView.setAdSize(AdSize.SMART_BANNER); adView.setAdUnitId(AD_UNIT_ID); // Add the AdView to the view hierarchy. The view will have no size // until the ad is loaded. RelativeLayout layout = (RelativeLayout) findViewById(R.id.linearLayout); layout.addView(adView); // Create an ad request. Check logcat output for the hashed device ID to // get test ads on a physical device. // phone test AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("87F3274F1BC1CC1EB640DFA9E6293717") .build(); // AC98C820A50B4AD8A2106EDE96FB87D4 // Start loading the ad in the background. adView.loadAd(adRequest); }