Android :: Change Internal Buffer Size Of Data Input Stream
Apr 1, 2010
I'm using this kind of code for my TCP/IP connection:
sock = new Socket(host, port);
sock.setKeepAlive(true);
din = new DataInputStream(sock.getInputStream());
dout = new DataOutputStream(sock.getOutputStream());
Then, in separate thread I'm checking din.available() bytes to see if there are some incoming packets to read. The problem is, that if a packet bigger than 2048 bytes arrives, the din.available() returns 2048 anyway. Just like there was a 2048 internal buffer. I can't read those 2048 bytes when I know it's not the full packet my application is waiting for. If I don't read it however - it'll all stuck at 2048 bytes and never receive more. Can I enlarge the buffer size of DataInputStream somehow? Socket receive buffer is 16384 as returned by sock.getReceiveBufferSize() so it's not the socket limiting me to 2048 bytes. If there is no way to increase the DataInputStream buffer size - I guess the only way is to declare my own buffer and read everything from DataInputStream to that buffer?
View 4 Replies
Jul 5, 2010
I use BufferedInputStream in my code: socket = new Socket(ip, Integer.parseInt(port)); socket.setReceiveBufferSize(64000); output = socket.getOutputStream(); input = new BufferedInputStream(socket.getInputStream(), 64000); I read incoming packets like this: if (input.available() != 0) { System.out.println("Get Packet: " + input.available() + " bytes"); byte[] b = new byte[input.available()]; input.read(b); incParser(b); }
View 2 Replies
View Related
Aug 12, 2010
I want to create a progress Bar for an FTP download. The server where I am downloading the file has all of its directories and files hidden. I want to display the progress of the download. Is there any way I can get the file size? Here is my current code:
FTP client = new FTP Client();
FTP client.setListHiddenFiles
FTP client.connect(host Part);
FTP client.login(user Name, password);
FTPclient.setFileType(FTP.BINARY_FILE_TYPE);
Input Stream instream = FTP client.retrieveFileStream(pathExcludingHostIncludingFirstSlash);
int l;
byte[] tmp = new byte[2048];
int update Counter = 0;
int bytes Downloaded = 0;
while ((l = instream.read(tmp)) != -1) {
Foss.write(tmp, 0, l);
bytes Downloaded+=2048;
update Counter++;
if(update Counter==3){
kilobytes Downloaded=(bytes Downloaded / 1024);
publish Progress((String[])null);
update Counter=0}
View 1 Replies
View Related
Jan 30, 2010
Is there a way to change how big the logcat buffer is? or how much is buffered back? Especially when using DDMS.
View 3 Replies
View Related
Feb 11, 2009
I have the following problem: I'd like to see the system log of two days ago and I cannot. I see only 3 last hours. How can I configure the system log size, location, severity?
View 6 Replies
View Related
Jun 17, 2009
This may be impossible but is there any way that I can get a smaller buffer size for AudioTrack than what is provided by getMinBufferSize method?
This is how I am instantiating AudioTrack right now: SR = 44100; bufSize = AudioTrack.getMinBufferSize(SR, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, SR, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, bufSize, AudioTrack.MODE_STREAM);
With sample rate of 44100, getMinBufferSize always returns 4800. If I try to make the buffer size smaller than 4800 then I get the following error message: E/AudioTrack( 318): Invalid buffer size: minFrameCount 1200, frameCount 600 E/AudioTrack-JNI( 318): Error initializing AudioTrack E/AudioTrack-Java( 318): [ android.media.AudioTrack ] Error code -20 when initializing AudioTrack. D/AndroidRuntime( 318): Shutting down VM W/dalvikvm( 318): threadid=3: thread exiting with uncaught exception (group=0x4000fe70) E/AndroidRuntime( 318): Uncaught handler: thread main exiting due to uncaught exception I/CheckinService( 59): From server: Intent { action=android.server.checkin.FOTA_CANCEL } E/AndroidRuntime( 318): java.lang.RuntimeException: Unable to start activity Does anyone has any ideas how to over come this problem?
View 2 Replies
View Related
Nov 14, 2009
The following works fine on a G1 but gives an error on the Samsung Galaxy. I was hoping cross-platform support would be better than this. See error below.
private final static int RATE = 44100; private final static int CHANNEL_MODE = AudioFormat.CHANNEL_CONFIGURATION_MONO; private final static int ENCODING = AudioFormat.ENCODING_PCM_16BIT; private AudioRecord recorder_; public boolean open() { int bufferSize = 4 * AudioRecord.getMinBufferSize(RATE, CHANNEL_MODE, ENCODING); recorder_ = new AudioRecord(AudioSource.MIC, RATE, CHANNEL_MODE, ENCODING, bufferSize);
last line gives the following on the Samsung Galaxy phone: 11-14 19:04:07.507: ERROR/AndroidRuntime(7617): java.lang.IllegalArgumentException: Invalid audio buffer size.
View 5 Replies
View Related
Aug 17, 2010
When I used BufferedInputStream and I specify a buffer size, Dalvik gives me this warning - Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
But right now, my buffer size is already at 8k. What am I doing wrong?
View 1 Replies
View Related
May 16, 2010
I know when the xml file is under /res/raw,I can do this by context.getResources().openRawResource(rid); but when the xml file is under /res/xml,how can I do it? You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
View 4 Replies
View Related
Dec 26, 2012
The closest I know of are mxplayer and vplayer. Any xda alternatives people know of?
View 2 Replies
View Related
Mar 15, 2010
The class Typeface has a couple of static factory methods which take different inputs. However, Input streams are not among themn (there is a way to load a file though). Is there a way around this apart from copying the font to a temporary file?
View 4 Replies
View Related
Jan 9, 2010
I am getting the input of a web page using Input Stream in = httpConnection.getInputStream(); I then use the XmlPullParser to check if an error has occurred. If no error has occurred, I then want to reset the Input Stream back to the beginning so that I can parse it through another function I have created. I tried in.reset(); but this does not work. Is this possible?
View 4 Replies
View Related
Aug 13, 2009
I'm running into a strange problem while reading from an Input Stream on the Android platform. I'm not sure if this is an Android specific issue, or something I'm doing wrong in general. The only thing that is Android specific is this call:
Input Stream is = getResources().openRawResource(R.raw.myfile);
This returns an Input Stream for a file from the Android assets. Anyways, here's where I run into the issue:
bytes[] buffer = new bytes[2];
is.read(buffer);
When the read() executes it throws an IOException. The weird thing is that if I do two sequential single byte reads (or any number of single byte reads), there is no exception. Ie, this works:
byte buffer;
buffer = (byte)buffer.read();
buffer = (byte)buffer.read();
Any idea why two sequential single byte reads work but one call to read both at once throws an exception? The Input Stream seems fine... is.available() returns over a million bytes (as it should).
Stack trace shows these lines just before the Input Stream.read():
java.io.IOException
at android.content.res.AssetManager.readAsset(Native Method)
at android.content.res.AssetManager.access$800(AssetManager.java:36)
at android.content.res.AssetManager$AssetInputStream.read(AssetManager.java:542)
Changing the buffer size to a single byte still throws the error. It looks like the exception is only raised when reading into a byte array.
If I truncate the file to 100,000 bytes (file is: 1,917,408 bytes originally) it works fine. Is there a problem with files over a certain size?
View 3 Replies
View Related
Mar 3, 2010
I found a problem with GZIP input stream when wrapping InputStream from HttpURLConnection. When the server response with Transfer- Encoding=chunked, Content-Encoding=gzip and Connection=Keep-Alive. The second post always return -1. After digging into the source code, I found the place that could be a bug: InflaterInputStream.java (line 190 to 192) if (inf.needsInput()) { fill(); } Because InflaterInputStream doesn't need more input, it doesn't try to read the end of chunked encoding (0x)(30 0a 0d) that cause the second post to return with -1 every time.
View 3 Replies
View Related
Aug 4, 2009
Have some tryed to pas databuffer on android by jni?
View 6 Replies
View Related
Sep 17, 2010
I have an input stream which is being converted to XML, and read. When I get down to some text elements in the XML, they are truncated. I believe the parser is dropping everything after escaped HTML such as & Here is the code getting the input stream and then getting the text element. Code...
View 2 Replies
View Related
Sep 24, 2009
I am working on a packet switched network. I want to capture the audio data from mic into a buffer at a desired sample rate.How can I capture the audio data from mic into a buffer instead of a file? Also how can I control the audio capture rate as per the desired sample rate?
View 2 Replies
View Related
Jul 23, 2009
I'm downloading text data from a web server, and getting an Input Stream. The data will be relatively large and delimited. I want to split this data by the deliminator and store each piece in the DB. Is it faster to read the Input Stream byte by byte to split the data and store each piece in the DB, or would it be faster to convert the Input Stream to a String and use an existing function such as Split?
View 2 Replies
View Related
Mar 16, 2010
I have experienced some trouble using VBOs, since the method glBufferData crashes when I try to copy data to the vertex buffer. Below is the smallest snippet of code that I found to generate the crash:
int numVert = 32; GL11 gl11 = (GL11)gl; testArray = new int[numVert * 3]; testBuffer = IntBuffer.wrap(testArray); gl11.glGenBuffers(1, testID, 0); gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, testID[0]); final int siz = testBuffer.capacity() * Integer.SIZE; gl11.glBufferData(GL11.GL_ARRAY_BUFFER, siz, testBuffer, GL11.GL_STATIC_DRAW); gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
testArray, testBuffer and testID are members of the class containing this code, declared as follows:
int[] testArray; IntBuffer testBuffer; int[] testID = {0};
I tried this code in several OpenGL applications which don't show any problem otherwise. The crash occurs specifically at the glBufferData() method call. If numVert is set to zero, then the crash doesn't occur.
View 4 Replies
View Related
Aug 29, 2010
I have been using the official lastfm client, and it has a few things that bug me, the main one being that if I'm listing to music, and my mobile rings, lastfm stays in front of the answer button so i cant receive calls.
I also tried "alastfm-player" and the buffer keeps running out, so the music skips, and today it done a thing where it played like 3 sec of 1 song, then played 3 sec of the next etc , for about 10 songs till i stopped it if i could just change a setting in alastfm-player to increase the buffer i would use that as i prefer it to the official client. any one know any other last FM players? i just use it for the "recommended" stream.
View 2 Replies
View Related
Jan 5, 2014
I have a xperia u, which has not external SD card slot..
Data partition is MUCH bigger than what I need (I'm using 500mb of 2gb) and I want to move obb files to data partition to free some space in SD partition..
View 9 Replies
View Related
Aug 12, 2010
I am trying to get a input stream from something like this.
CODE:.........
And then call parse on the parser instance i Created. SOm how i get nothing . Works fine if I use a server XML....
View 1 Replies
View Related
Jan 12, 2010
1) Our Android app will store data in a built-in SQLite DB. I see the DB can throw android.database.sqlite.SQLiteFullException, but there's no exact info in API what is the limit. Could anyone tell what are the size limits for a DB in order not to get into the SQLiteFullException? I assume DB will store data in device's internal storage (versus SDCard). Am I right? Given SQLite DB is just a file, probably the DB size is limited with free internal storage space. Again - Am I right? If yes, then what is the internal storage size on Android? How to detect it? Does it vary on a device model basis or OS version basis? 2) We'll also need to save app settings. I think SharedPreferences will fit nicely. However the question is - are SharedPreferences saved to the internal storage too? If yes, then is it the same storage where the DB stores its file.
View 1 Replies
View Related
Oct 15, 2010
Is there a way to set the emulator's internal storage size? It is currently set to a fairly low value. Also, while searching for the answer to this question (which I didn't find), I ran across several threads which seemed to indicate that many phones have a very limited amount of internal storage. If I have an application which is 30 Mb (due to graphics and audio resources), is this going to be too large for most people to use. Should I be looking to install my application on the SD card instead (can this only be done on version 2.2 systems?).
View 3 Replies
View Related
Aug 23, 2010
I'm writing an image file up loader for android for my favorite image gallery software and it uses FTP.
I've started using Apache-Commons Net FTP as my ftp library based on past stack overflow questions. Like so:
FTP Client ftp = new FTP Client();
try{
ftp.connect(host);
Log.i(TAG,"we connected");
if(!ftp.login(user,pass)){
ftp.logout();
//TODO: alert user it didn't happen
return;
}
String reply Status = ftp.get Status();
Log.i(TAG,reply Status);
int reply Code = ftp.triplicate();
if (!FTPReply.isPositiveCompletion(reply Code))
{
ftp.disconnect();
//TODO: alert user it didn't happen
return;}
Log.i(TAG,"we logged in");
ftp.changeWorkingDirectory(path);
ftp.setFileType(ftp.BINARY_FILE_TYPE);
for(int i = 0; i < content Uris.size(); i++){
Log.i(TAG,"uploading new file");
Uri stream = (Uri) content Uris.get(i);
//InputStream in = openFileInput(getRealPathFromURI(stream));
Input Stream in =this.getContentResolver().openInputStream(stream);
BufferedInputStream buffing=null;
buffing=new BufferedInputStream(in);
ftp.setFileType(ftp.BINARY_FILE_TYPE);
boolean Store = ftp.storeFile("test.jpg", buffing);
Log.i(TAG, "uploaded test");
View 1 Replies
View Related
Sep 6, 2010
I am facing problem here: http://stackoverflow.com/questions/3584297/installing-application-on-sd-card-in-android-sdk-2-2 , regarding application installation.
In above question, you can view the image in which "Internal Phone Storage" is showing where only 43.38 MB is showing , and in latest android phone, i know it is coming with higher space, i have seen 13.45 GB in Samsung Galaxy Android Phone.
But Right now, i am using HTC Hero, so my questions are:
Is there any way to increase ROM size without any side-effect? How do i increase ROM Size?
View 2 Replies
View Related
Jun 11, 2010
Currently I want to develop one Activity to allow the user to see the screens/activites of all running tasks , then the user can select one of them to switch it to foreground. As I known, HTC Sence seems already to have this implementation for Home screen, to display the thumbnail of all Home panels in one screen. Does anybody know how to access screen stack in Android?
View 1 Replies
View Related
Nov 1, 2010
According to android information system; the max internal memory is 147mb, I have 14.75 mb (9%) left. This means I have used 132,75mb. According to app brain, I have 69 apps with a total of 140mb. Surely the move to SD built into froyo should move more than 7.25mb? Most of my apps have the feature. I know this is the poorest way of getting apps to SD but surely it should move more than that? I am going to have a go at the noob guide to moving apps to SD later to see if it improves things. I need to do something. I am at a stage now where apps not update. i have to uninstall the old version and then reinstall the new version.
View 10 Replies
View Related
Mar 4, 2010
I'm making an Android Java app game (although this question applies to all languages really) and hope to release the first version soon. I'm nervous about how I save data in my game. My problem is that, if in a later update, I decide to store more data or store the same data in a different way, I need to be careful I don't lose or corrupt data for users that upgrade (i.e. I want users to be able to use data created by an old version in the new version, like their high scores from before).For example, say I want to save high scores in version 1.
View 3 Replies
View Related
Jul 28, 2013
i have onlt 750mb internal memory , pre installed app also 450mb , so how to increase that partiaion, can in mount this partiton to SD partition
View 2 Replies
View Related