Android - How to get application name? (Not package name)

后端 未结 12 2224
天涯浪人
天涯浪人 2020-11-27 15:17

In my manifest I have:

  

        
12条回答
  •  被撕碎了的回忆
    2020-11-27 15:45

    In Kotlin, use the following codes to get Application Name:

            // Get App Name
            var appName: String = ""
            val applicationInfo = this.getApplicationInfo()
            val stringId = applicationInfo.labelRes
            if (stringId == 0) {
                appName = applicationInfo.nonLocalizedLabel.toString()
            }
            else {
                appName = this.getString(stringId)
            }
    

提交回复
热议问题