File tree Expand file tree Collapse file tree 4 files changed +12
-6
lines changed
admob/app/src/main/java/com/google/samples/quickstart/admobexample
analytics/app/src/main/java/com/google/firebase/quickstart/analytics Expand file tree Collapse file tree 4 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ protected void onCreate(Bundle savedInstanceState) {
6060 checkIds ();
6161
6262 // Initialize the Google Mobile Ads SDK
63- MobileAds .initialize (this , getString ( R . string . admob_app_id ) );
63+ MobileAds .initialize (this );
6464
6565 mAdView = findViewById (R .id .adView );
6666 AdRequest adRequest = new AdRequest .Builder ().build ();
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class MainActivity : AppCompatActivity() {
3737 checkIds()
3838
3939 // Initialize the Google Mobile Ads SDK
40- MobileAds .initialize(this , getString( R .string.admob_app_id) )
40+ MobileAds .initialize(this )
4141
4242 val adRequest = AdRequest .Builder ().build()
4343
Original file line number Diff line number Diff line change @@ -255,11 +255,14 @@ private void recordImageView() {
255255 * we change fragments.
256256 */
257257 private void recordScreenView () {
258- // This string must be <= 36 characters long in order for setCurrentScreen to succeed .
258+ // This string must be <= 36 characters long.
259259 String screenName = getCurrentImageId () + "-" + getCurrentImageTitle ();
260260
261261 // [START set_current_screen]
262- mFirebaseAnalytics .setCurrentScreen (this , screenName , null /* class override */ );
262+ Bundle bundle = new Bundle ();
263+ bundle .putString (FirebaseAnalytics .Param .SCREEN_NAME , screenName );
264+ bundle .putString (FirebaseAnalytics .Param .SCREEN_CLASS , "MainActivity" );
265+ mFirebaseAnalytics .logEvent (FirebaseAnalytics .Event .SCREEN_VIEW , bundle );
263266 // [END set_current_screen]
264267 }
265268
Original file line number Diff line number Diff line change @@ -212,11 +212,14 @@ class MainActivity : AppCompatActivity() {
212212 * we change fragments.
213213 */
214214 private fun recordScreenView () {
215- // This string must be <= 36 characters long in order for setCurrentScreen to succeed .
215+ // This string must be <= 36 characters long.
216216 val screenName = " ${getCurrentImageId()} -${getCurrentImageTitle()} "
217217
218218 // [START set_current_screen]
219- firebaseAnalytics.setCurrentScreen(this , screenName, null /* class override */ )
219+ firebaseAnalytics.logEvent(FirebaseAnalytics .Event .SCREEN_VIEW ) {
220+ param(FirebaseAnalytics .Param .SCREEN_NAME , screenName)
221+ param(FirebaseAnalytics .Param .SCREEN_CLASS , " MainActivity" )
222+ }
220223 // [END set_current_screen]
221224 }
222225
You can’t perform that action at this time.
0 commit comments