Post installation of dynamic module, if we are accessing any resource through Resources#getIdentifier(String name, String defType, String defPackage) method which returns 0 as resourceId
We have added only one resource in our drawable folder i.e default_refer.png and made some changes in KotlinSampleActivity.
Kindly suggest what we are doing wrong.
class KotlinSampleActivity : BaseSplitActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_feature_kotlin)
// not working
try {
ContextCompat.getDrawable(this, resources.getIdentifier("default_refer", "drawable", packageName))
} catch (e: Exception) {
e.printStackTrace()
}
// working
try {
ContextCompat.getDrawable(this, R.drawable::class.java.getField("default_refer").getInt(null))
} catch (e: Exception) {
e.printStackTrace()
}
// working
try {
ContextCompat.getDrawable(this, R.drawable.default_refer)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
Hi,
Post installation of dynamic module, if we are accessing any resource through Resources#getIdentifier(String name, String defType, String defPackage) method which returns 0 as resourceId
We have added only one resource in our drawable folder i.e default_refer.png and made some changes in KotlinSampleActivity.
Kindly suggest what we are doing wrong.