Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. @Override
  2. protected void onCreate(Bundle savedInstanceState) {
  3. super.onCreate(savedInstanceState);
  4.  
  5. // Create an ad.
  6. adView = new AdView(this);
  7. adView.setAdSize(AdSize.BANNER);
  8. adView.setAdUnitId(AD_UNIT_ID);
  9.  
  10. // Add the AdView to the view hierarchy. The view will have no size
  11. // until the ad is loaded.
  12. LinearLayout layout = new LinearLayout(this);
  13. layout.setOrientation(LinearLayout.VERTICAL);
  14.  
  15. // Create an ad request.
  16. // get test ads on a physical device.
  17. AdRequest adRequest = new AdRequest.Builder()
  18. .addTestDevice(TestDeviceID)
  19. .build();
  20.  
  21. // Start loading the ad in the background.
  22. adView.loadAd(adRequest);
  23.  
  24. //Request full screen
  25. requestWindowFeature(Window.FEATURE_NO_TITLE);
  26. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  27. WindowManager.LayoutParams.FLAG_FULLSCREEN);
  28.  
  29. //Create a displayMetrics object to get pixel width and height
  30. metrics = new DisplayMetrics();
  31. getWindowManager().getDefaultDisplay().getMetrics(metrics);
  32. width = metrics.widthPixels;
  33. height = metrics.heightPixels;
  34.  
  35. //Create and set GL view (OpenGL View)
  36. myView = new MyGLSurfaceView(MainActivity.this);
  37. layout.addView(adView);
  38. layout.addView(myView);
  39.  
  40.  
  41. //Create a copy of the Bundle
  42. if (savedInstanceState != null){
  43. newBundle = new Bundle(savedInstanceState);
  44. }
  45.  
  46. //Set main renderer
  47. setContentView(layout);
  48.  
  49. }
  50.  
  51. @Override
  52. protected void onCreate(Bundle savedInstanceState) {
  53. super.onCreate(savedInstanceState);
  54.  
  55. // Create an ad.
  56. adView = new AdView(this);
  57. adView.setAdSize(AdSize.BANNER);
  58. adView.setAdUnitId(AD_UNIT_ID);
  59. adView.setBackgroundColor(Color.TRANSPARENT);
  60. // Add the AdView to the view hierarchy. The view will have no size
  61. // until the ad is loaded.
  62. RelativeLayout layout = new RelativeLayout(this);
  63. layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  64. // Create an ad request.
  65. // get test ads on a physical device.
  66. AdRequest adRequest = new AdRequest.Builder()
  67. .addTestDevice(TestDeviceID)
  68. .build();
  69.  
  70. // Start loading the ad in the background.
  71. adView.loadAd(adRequest);
  72.  
  73. //Request full screen
  74. requestWindowFeature(Window.FEATURE_NO_TITLE);
  75. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  76. WindowManager.LayoutParams.FLAG_FULLSCREEN);
  77.  
  78. //Create a displayMetrics object to get pixel width and height
  79. metrics = new DisplayMetrics();
  80. getWindowManager().getDefaultDisplay().getMetrics(metrics);
  81. width = metrics.widthPixels;
  82. height = metrics.heightPixels;
  83.  
  84. //Create and set GL view (OpenGL View)
  85. myView = new MyGLSurfaceView(MainActivity.this);
  86. RelativeLayout.LayoutParams adParams =
  87. new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
  88. RelativeLayout.LayoutParams.WRAP_CONTENT);
  89. adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
  90. adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
  91.  
  92. layout.addView(myView);
  93. layout.addView(adView, adParams);
  94.  
  95.  
  96. //Create a copy of the Bundle
  97. if (savedInstanceState != null){
  98. newBundle = new Bundle(savedInstanceState);
  99. }
  100.  
  101. //Set main renderer
  102. setContentView(layout);
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement