Which is best way to define constants in android, either static class, interface or xml resource?

后端 未结 6 1263
独厮守ぢ
独厮守ぢ 2020-12-07 14:28

I\'m developing an android application which uses web service to get data from server, for that I\'m having three different set of URLs to point development system, test ser

6条回答
  •  星月不相逢
    2020-12-07 15:04

    I am glad someone asked this ... plus one!

    Project resources need access to Context, which is not available in static methods (unless you pass it in etc), but always available in Activity -- there seems to be a preferential connection between resources and layouts. For app variables and constants that may be processed in static methods I create an abstract class and do a static import (of this constants class) in all the other project class files.

    PVS

提交回复
热议问题