如何在运行时将元数据信息写入Android Manifest [英] How to write meta-data info to Android Manifest at runtime

查看:179
本文介绍了如何在运行时将元数据信息写入Android Manifest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以编辑android manifest组件,例如,将其设置为启用/禁用等.我想在运行时将meta值标签插入android manifest的应用程序标签中.如何直接写入android清单?

I know its possible to edit a android manifest component, for example, set it enabled/disabled etc. I'd like to insert meta value tag into the application tag of the android manifest at runtime. How can i write directly into the android manifest ?

这是我想直接写入应用程序的android清单中的字符串:

here is the string i want to write directly into my app's android manifest:

<meta-data android:name="my_api_key" android:value="mykey124" />

,它必须在application标记内.

and it must be within the application tag.

推荐答案

您无法在运行时编辑清单.

You can't edit the manifest at runtime.

如果您需要运行时解决方案,则应尝试其他方法,例如共享首选项或持久保存价值的方法.

If you need runtime solution, you should try other ways like share preference or something can save value persist.

如果不只是将其放入清单中,请以Google Play服务为例:

If not just put it in manifest, take google play service for Example:

<application>
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    .....
</application>

这篇关于如何在运行时将元数据信息写入Android Manifest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆