Will the code below be effective? I mean, will it actually be run just one and the result will be cached in the property, so the next call will not re-run the method anymore?
public static final String LOG_TAG = MyApplication.getContext().getApplicationInfo().name;
Somehow I cannot find it anywhere.
comment.
Since you guys seem to focus on not important things, here’s the changed code:
public static final String SomeVar = MyApplication.someMethod();
You can’t do that, since
Application.getContext()method isn’tstatic.EDIT: I see you edited your question: So if your
MyApplication.someMethod()method isstatic, than ofcourse it works, andsomeMethod()will be only called once, unless your class gets destroyed and recreated by the garbage collector.