I want to find all hard-coded strings in my code to move them into strings.xml
file for future localization. Such as :
Toast.makeText(context,"Hardcoded text",LENGTH_SHORT).show();
I using Android Studio.
To run lint inside Android Studio just go to the Analyze menu and select Inspect code… select your scope (e.g. Workspace) then click Ok. The hardcoded strings you search for will be present in two groups: Hardcoded text — reports all the hardcoded text in xml layout files. e.g.
The term hardcoded string refers to a string that doesn't depend on the input to the program but it also has connotations of being hard to change, meaning that you might have to edit the code in one or more places to change it.
Go to Analyze
> Run Inspection By Name...
(Ctrl+Alt+Shift+I)
and type:
Hardcoded Text
to find the hardcoded strings in
the .xml files;Hardcoded Strings
to find the hardcoded strings in the .java files.Run it against the whole project, and you should get an inspection results panel that will show the hardcoded text instances.
This answer hasn't getting to me any result.
Nonetheless, for future searches :
In Android Studio 1.2.2 added new Option Hardcoded strings
(not a Hardcoded text
) and this getting to me perfect searches result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With