Phew, now we've downloaded
the container, we can go ahead and
actually do something in
our app that uses it.
We can get things out and
use them where we want.
It's a simple matter of knowing
the key and retrieving the value.
First Get the ContainerHolder.
Then retrieve the value by key.
Obviously, you have to
know the exact key.
Here's how we get the daily
special: we just call getString and
pass the key daily-special.
And that's all there is too it.
Whenever the daily special updates, your
app will automatically get the latest
value without you having to
make any changes to the code.
Note, though, that the update only
takes effect when the app is restarted,
because the code to get the container
is in the onCreate method.
To try it out, update your app to
show the latest daily special.
In the ShowDailySpecial activity,
define the method Update daily special
that get's the daily special
out of the container and
updates the relevant text view so
that your users can actually see it.
And make sure that you actually
call update daily special
in the on create method.
Run the app and show the daily special.
And then In the Tag Manager dashboard,
go ahead and change the daily special.
Don't forget to publish your changes,
and
then restart your app and
see if you get the new value.
And hopefully the daily
special will have changed.
And go ahead and
check all the boxes when you're done.
حسنًا، والآن قمنا يتنزيل
الحاوية ويمكننا الاستمرار
وفي الواقع فعل شيء في
تطبيقنا الذي يستخدمها.
يمكننا الحصول على أشياء من الخارج
واستخدامها حيثما نريد.
إنها مسألة بسيطة لمعرفة
المفتاح واسترداد القيمة.
احصل أولاً على ContainerHolder.
ثم استرد القيمة بواسطة المفتاح.
وبشكل واضح، عليك معرفة المفتاح الصحيح.
وهنا يمكنك الحصول على التمايز
اليومي: نستدعى getString فقط
وندخل المفتاح الخاص بالتمايز اليومي.
وهذا كل ما يوجد أيضًا.
حينما يتم تحديث التمايز اليومي، سيحصل
تطبيقك على أحدث
قيمة تلقائيًا دون إجراء
أي تغييرات على الرمز.
ومع ذلك يُرجى ملاحظة أن التحديث
يؤثر فقط عند إعادة تشغيل التطبيق،
نظرًا لوجود الرمز اللازم للحصول على
الحاوية في طريقة onCreate.
لتجربة ذلك، حدّث تطبيقك
لعرض أحدث تمايز يومي.
في النشاط ShowDailySpecial،
حدد طريقة تحديث التمايز اليومي
التي تطرد على التمايز اليومي
من الحاوية
وتقوم بتحديث طريقة عرض النص ذات الصلة لكي
يتمكن المستخدمون من رؤيتها في الواقع.
وتأكد من استدعاء تحديث
التمايز اليومي بالفعل
في طريقة on create.
شغل التطبيق واعرض التمايز اليومي.
ثم من لوحة معلومات Tag Manager،
استمر وغيّر التمايز اليومي.
لا تنس نشر التغييرات التي تجريها،
ثم أعد تشغيل تطبيقك
وانظر إذا ما حصلت على القيمة الجديدة.
ونأمل في تغيير
التمايز اليومي.
واستمر وتحقق من
جميع المربعات عندما تنتهي.
Ufa, agora que baixamos
o contêiner, podemos ir em frente
e realmente fazer alguma coisa
em nosso aplicativo que o use.
Podemos tirar coisas
e usá-las onde quisermos.
É uma simples questão de conhecer
a chave e recuperar o valor.
Primeiro obtenha o ContainerHolder.
E depois recupere o valor por chave.
É claro que você precisa
saber a chave exata.
Veja como conseguimos o prato
do dia: chamamos getString
e passamos a chave
daily-special.
E
pronto.
Sempre que o prato do dia é atualizado,
seu aplicativo obtém
automaticamente o valor mais recente
sem você precisar
fazer alterações no código.
Mas, observe
que a atualização só passa a vigorar
quando o aplicativo é reiniciado,
porque o código
para obter o contêiner
está no método onCreate.
Experimente, atualize seu aplicativo
para mostrar o prato do dia mais recente.
Na atividade ShowDailySpecial,
defina o método
updateDailySpecial,
que obtém o prato do dia
do contêiner
e atualiza
a exibição de texto pertinente
, de modo que os usuários
possam realmente vê-lo.
Certifique-se de que você realmente
chama updateDailySpecial
no método onCreate.
Execute o aplicativo
e mostre o prato do dia.
Em seguida,
no painel do gerenciador de tags,
vá em frente
e altere o prato do dia.
Não esqueça
de publicar suas alterações
, em seguida, reinicie seu aplicativo
e veja se obteve o novo valor.
Espero que o prato do dia
tenha sido alterado.
Vá em frente e marque
todas as caixas quando tiver terminado.
哟 现在我们已经下载了容器 我们可以继续操作
并且在使用它的应用中真正做些事情
我们可以得出一些东西并将其用在我们想要的地方
了解键和检索数据简直是小菜一碟
首先获取 ContainerHolder
然后通过键检索数值
很明显 你必须知道确切的键
这是我们获取每日特色菜的方法:我们只要调用 getString 并
传递关键每日特色菜
这就是全部要做的
每当更新每日特色菜时 应用将自动获取最新的值
无需对代码做任何更改
但是注意 只有当应用重新启动时更新才能生效
因为获取容器的代码位于 onCreate 方法内
要进行尝试 可更新应用以显示最新的每日特色菜
在 Show Daily Special Activity 中 定义更新 Update daily special 方法
该方法可从容器中获得每日特色菜;
并更新相关的文本视图 使用户能够真正看到它
确保在 onCreate 方法中实际调用
更新每日特色菜
运行应用并显示每日特色菜
然后在 Tag Manager 信息中心中 继续操作并更改每日特色菜
别忘了发布你的更改
然后重新启动应用 查看是否得到了新值
希望每日特色菜能有所变化
继续操作 并在完成时勾选所有方框