Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to extract a string with an automatically generated resource name for a java file in Android Studio?

In Android Studio, Alt + Enter > "Extract String Resource" in a java file will open the following window:

enter image description here

Please note that the Resource name field is blank. However, the window will be like the following for a layout XML file: enter image description here

Please note the Resource name field is filled automatically.

How can the Resource name field be filled with an automatically generated name for java files too?

It thought the Resource name was filled automatically for all types of files before the current version of Android Studio (2.1), but I could be wrong.

[edit] 2018-05-29: I want to emphasize the question is about "automatically generated resource name", not about whether one can extract a hard-coded string. Extracting a hard-coded string from a java file has always been available, but the automatic name generation is not there.

like image 777
Hong Avatar asked Oct 17 '25 01:10

Hong


1 Answers

You can use this software to do this automatically https://www.jetbrains.com/help/idea/2016.2/recognizing-hard-coded-string-literals.html

I had a mistake with the link (thanks for giving me a bad reputation) , however this question is duplicated many times...

I hope this help you, and next time, think that we spend our time only for help other people. Good luck friend!

How can I find all RELEVANT hard coded strings in Android Studio?

Auto Generate @String reference in Android Studio

Android: resource String automatic generation

Possible to highlight hard-coded string literals and navigate between them?

How can I find all hard coded strings in my project in Android Studio

What is the short cut to extract strings from Android code into the strings.xml file in Intellij?

like image 158
garatu Avatar answered Oct 19 '25 18:10

garatu