How to do localization in smali files?

孤者浪人 提交于 2019-12-08 11:00:29

问题


I have an app on forein language and I want to traslete it fully for example in the smali file I have this programming code:

const-string v1, "Hello"

How I can add reference to the string.xml file from this smali code?


回答1:


If you need to do it in com.xxx.yyy.HomeActivity, and your localized string'id in R.java is 0x7f050000. Use the code below to replace the code const-string v1, "Hello"

invoke-virtual {p0}, Lcom/xxx/yyy/HomeActivity;->getResources()Landroid/content/res/Resources;

move-result-object v2

const/high16 v3, 0x7f050000

invoke-virtual {v2, v3}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

move-result-object v1


来源:https://stackoverflow.com/questions/38565350/how-to-do-localization-in-smali-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!