Resources.getSystem() vs getResources()

后端 未结 3 2070
死守一世寂寞
死守一世寂寞 2021-02-07 07:10

I am new to Android and I am learning the SDK myself from resource available over the net.

I came across a situation now. I am trying the below code:

Type 1:

3条回答
  •  迷失自我
    2021-02-07 07:45

    All 3 return the same value, but Resources.getSystem() references to the system resources and might cause a crash if used incorrectly.

    The advised usage is "getString(android.R.string.cancel);"

    It is also used as such in the WalkieTalkieActivity.java code on the Android developer website.

提交回复
热议问题