Dear Sirs:
I have a strange issue when i use network.download API,i can download mp3 from google TTS when i use corona SDK simulation in MAC book.But when i export to a APK file to install in Android mobiles or tablets (samsung,sony…etc.), It doesn’t download any mp3 files to my devices.I can’t find why it happens,the main code is below:
function string.urlEncode( str ) if ( str ) then str = string.gsub( str, "\n", "\r\n" ) str = string.gsub( str, "([^%w])", function (c) return string.format( "%%%02X", string.byte(c) ) end ) str = string.gsub( str, " ", "+" ) end return str end local function networkListener( SoundTable) return function( event ) if ( event.isError ) then print( "Network error - download failed" ) elseif ( event.phase == "began" ) then print( "Progress Phase: began" ) elseif ( event.phase == "ended" ) then print( "finish download file" ) end end end local headers = { ["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8", ["Accept-Charset"] = "utf-8" } local params = {} params.progress = true params.headers=headers downloadSounds=function( SoundTable,fileTitle) for i=1,#SoundTable do network.download("http://www.translate.google.com/translate\_tts?ie=utf-8&tl=zh-tw&client=tw-ob&q="..string.urlEncode(SoundTable[i]), "GET", networkListener(SoundTable), params, fileTitle.."\_"..i..".mp3", system.DocumentsDirectory ) end end