Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
136 views
in Technique[技术] by (71.8m points)

java - How can I make base url dynamically in Appconstants class

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...