different behaviour of app in Nexus 7 and LG Optimus LTE

大城市里の小女人 提交于 2019-12-24 08:49:06

问题


My app writes a file called filename.dat in the /sdcard folder
I can delete this file from adb in the tablet, using the command adb shell rm /sdcard/filename.dat
I use this tablet only for development and nothing else, so I have very few apps installed on it, and those are also specific to things that I need to develop, such as file explorer
I tried the same thing in LG Optimus LTE phone that is actively being used, and so has lots of other apps installed, including those needed for personl daily work
When I try the same command,
adb shell rm /sdcard/filename.dat
in the LG phone, it refuses to do so
rm failed for /sdcard/filename.dat, Permission denied
Why is it behaving this way?

More importantly, in the program that I am testing, it works fine all the time in the Nexus 7, but when I try to run it on the phone, it works fine the first time, but when I do so the second time, one of the variables in the program starts getting NaN values (I have tracked it down to be due to an Infinity/Infinity division taking place on one of the lines), then everytime I execute it again, it shows these NaN values. The program is too long to troubleshoot for someone unfamiliar with it I guess, but it uses AudioTrack and AudioRecord classes to take sound input, perform some FFT and DSP operations on it, then play it back.

What I really need to know is, what is it that is different between tablet and phone, that might be causing a problem like this, and what are the other things I might need to consider?

I initialize the AudioRecord and AudioTrack as

int min = AudioRecord.getMinBufferSize(16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
record = new AudioRecord(MediaRecorder.AudioSource.VOICE_COMMUNICATION, 16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, min);
int maxJitter = AudioTrack.getMinBufferSize(SAMPLE_FREQUENCY, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT);
track = new AudioTrack(AudioManager.MODE_IN_COMMUNICATION, 16000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, maxJitter, AudioTrack.MODE_STREAM);  

I think this might be relevant to this particular program, since using something other than MODE_IN_COMMUNICATION, such as MODE_VOICE_CALL, seems to compile fine but gives similar problems, even in the Nexus 7.


回答1:


You could try System.getenv("EXTERNAL_STORAGE") to get the external storage directory instead of using /sdcard/. In my experiences this was the same in most cases. But this should give you a correct output directory every time.



来源:https://stackoverflow.com/questions/19310648/different-behaviour-of-app-in-nexus-7-and-lg-optimus-lte

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!