Return to Video

Overview of Code to Load The Container

  • 0:00 - 0:04
    So far, we've been working
    in the Tag Manager UI, but
  • 0:04 - 0:08
    now it's time to code our app to
    use the daily special variable.
  • 0:08 - 0:12
    So what we're going to do is
    add the default container
  • 0:12 - 0:13
    to our Android Studio project.
  • 0:13 - 0:18
    And the default container is
    the thing that you just downloaded.
  • 0:18 - 0:22
    So the default container contains the
    initial values for the variables, but
  • 0:22 - 0:25
    we're going to want our code
    to get the latest values.
  • 0:25 - 0:30
    So we'll add code to download
    the latest container into our app, and
  • 0:30 - 0:36
    we'll do that in the onCreate
    Method in the main activity.
  • 0:36 - 0:40
    It's important to save
    a reference to the container so
  • 0:40 - 0:43
    that you can get hold of the container
    from any other place in your app.
  • 0:43 - 0:45
    And then throughout your app,
  • 0:45 - 0:50
    wherever you need, you get the container
    and you get what you want out of it
  • 0:50 - 0:53
    by retrieving the value
    of the relevant key.
  • 0:53 - 0:55
    And that's a simple get call.
  • 0:55 - 1:00
    Now then,all of these tasks, adding
    the default container to a project and
  • 1:00 - 1:03
    writing this code,
    are one time only tasks.
  • 1:03 - 1:07
    After you've done these steps, the only
    thing you need to do when the special of
  • 1:07 - 1:12
    the day changes is to update the value
    in Tag Manager and publish the change.
  • 1:12 - 1:16
    So the first thing is to find the file
    that you downloaded from Tag Manager.
  • 1:16 - 1:20
    It likely starts with GTM and it will
    probably be in your downloaded folder.
  • 1:20 - 1:22
    You're going to have to rename it.
  • 1:22 - 1:25
    The name must only have
    lowercase letters and
  • 1:25 - 1:29
    underscores, no hyphens allowed.
  • 1:29 - 1:33
    For some reason the downloaded file
    has capital letters and hyphens so
  • 1:33 - 1:34
    you definitely have to rename it.
  • 1:34 - 1:38
    You need to copy a file
    into the raw folder
  • 1:38 - 1:40
    in the res folder in Android Studio.
  • 1:40 - 1:44
    And you'll need to
    create the raw folder.
  • 1:57 - 2:01
    So the file that's now in the raw folder
    holds the initial default value for
  • 2:01 - 2:03
    everything in the Tag Manager container.
  • 2:04 - 2:05
    Usually, your app will
  • 2:05 - 2:08
    get what it needs from the latest
    version of the container.
  • 2:08 - 2:10
    But it's required to
    have a default container,
  • 2:10 - 2:13
    even if it's just an empty file.
  • 2:13 - 2:16
    Okay, go ahead and do these steps now.
Cím:
Overview of Code to Load The Container
Leírás:

more » « less
Video Language:
English
Team:
Udacity
Projekt:
UD876-2 - Google Play Services - Analytics
Duration:
02:17

English subtitles

Felülvizsgálatok Compare revisions