I got a problem on my Java code on Android Studio: I got this warning " Duplicate string literal found in 'com.example.xyz.MainActivity' " on my code on ConnectThread (private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");) and on MainActivity ( UUID applicationUUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); ) subprograms. Both of them should be used for a bluetooth connection on a phone apk connection to other device. What should I do and what you recommend to me? Thanks for help!
2 Answers
0
votes
0
votes
it says that you have duplicated variable:
"00001101-0000-1000-8000-00805f9b34fb"
To avoid this warning you should extract it to the constant:
private static final String HASH = "00001101-0000-1000-8000-00805f9b34fb"
and then use HASH variable instead a literal:
UUID MY_UUID = UUID.fromString(HASH);
UUID applicationUUID = UUID.fromString(HASH);