Android music garbled problem modification, android garbled
The following is a summary of the garbled modification of music names, albums, and music in the Android music player:
Method 1: In frameworks \ base \ media \ java \ android \ media \ MediaScanner. java, modify the handleStringTag function.
Add the character encoding conversion to this function;
<span style="font-family:KaiTi_GB2312;font-size:18px;">/*add by tanfusheng @20150110 start */ private boolean isEncoding(String value,String code) throws UnsupportedEncodingException{ return value.equals(new String(value.getBytes(code),code)); } /*add by tanfusheng @20150110 end */ public void handleStringTag(String name, String value) { /*add by tanfusheng @20150110 start */ try{ if(isEncoding(value,"ISO-8859-1")){ value = new String(value.getBytes("ISO-8859-1"),"GBK"); } }catch(UnsupportedEncodingException e){ e.printStackTrace(); } /*add by tanfusheng @20150110 end */</span>
You can.
Method 2: modify it in frameworks \ av \ media \ libmedia \ MediaScannerClient. cpp:
<span style="font-family:KaiTi_GB2312;font-size:18px;">void MediaScannerClient::endFile(){if (mLocaleEncoding != kEncodingNone) {int size = mNames->size();+ int count = 0;uint32_t encoding = kEncodingAll;uint32_t tmpEncoding = kEncodingAll;uint32_t srcEncoding = kEncodingNone;for (int i = 0; i < mNames->size(); i++) {tmpEncoding = possibleEncodings(mValues->getEntry(i));// If no multibyte encoding is detected or GBK is the only possible multibyte encoding, just ignore- if( (kEncodingNone != tmpEncoding) && (kEncodingCP1252 != tmpEncoding)- && ((kEncodingGBK | kEncodingCP1252) != tmpEncoding) ) {- encoding &= tmpEncoding;+ if( (kEncodingNone == tmpEncoding) || ((kEncodingGBK | kEncodingCP1252) == tmpEncoding) ) {+ continue;}++ if( kEncodingCP1252 == tmpEncoding ) {+ ++count;+ continue;+ }++ encoding &= tmpEncoding;LOGV("value: %s, tmpEncoding: %x\n", mValues->getEntry(i), tmpEncoding);}++ if(count >= 2) {+ encoding = kEncodingAll;+ }LOGV("possibleEncodings: %x\n", encoding);...}</span>
"+" Indicates the code to be added and "-" indicates the code to be deleted.
I hope this garbled problem can be used. If it is changed like this, there will be garbled characters, which is the problem of a single music. I have to listen to it and modify the encoding method of the music, the method can be Baidu.