如何在Appconstants类中动态创建基本URL [英] How can I make base url dynamically in Appconstants class

查看:361
本文介绍了如何在Appconstants类中动态创建基本URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的旧项目,在应用程序常量类中仅静态定义了一个基本URL。现在我需要在登录活动中实现一个微调器,该微调器具有3个微调器值,并且每个值静态携带一个基本URL。因此,当用户从微调器中选择值时,它将访问基本URL并进行相应的记录。现在我的问题是我可以更改吗在应用程序常量类中以编程方式创建基本网址。这样我就不需要更改整个代码或进行设置类。

I have an existing old project where only one base URL is defined statically in app constant class. Now I need to implement a spinner in login activity which have 3 spinner value and each value carry one base URL statically.So when user select value from spinner it will access base URL and logging accordingly.Now my question is can I change base URL programmatically in App constant class. so that i do not need to change entire code or make a setting class.

推荐答案

根据我的理解,您需要在具有3个静态值且每个值带有一个不同的日志记录路径。

As per my understanding you need to implement a spinner in an existing project which is having 3 static value and each value carry a different path for logging.

据我了解,由于它是常量类,因此无法动态创建基本URL。

First thing as per my understanding you can't make Base URL dynamically because it's constant class.

现在您可以理解我的理解了,您可以在日志记录活动中获取微调器项目选择上的URL,如果日志记录结果成功,则将URL值保存在Sharedpreference中,以便您可以从共享首选项。

Now coming to your point if I understand you correctly, you can get URL on spinner item select in logging activity and if logging result is success then save URL value in Sharedpreference so that you can get this value in all your activity from Sharedpreference.

请记住,这只会给您一条路径。

Remember this will get you only one path.

这篇关于如何在Appconstants类中动态创建基本URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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