Android :: Chunked Encoding - GZIP Input Stream
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
Mar 24, 2009
I am having a specific problem that is preventing me using the android SDK from work. We are using a MS Proxy here that all internet traffic has to go through. The problem seems to be when the emulator is trying to access a site that uses 'Transfer-Encoding: chunked' If I attempt to download www.nds.com (no chunked encoding) into the browser, it works fine. However if I try to go to www.google.com (uses chunked encoding), the browser fails with the message: can't determine content length, and client wants to keep connection opened My feeling (and I'm no expert in this area) is that the underlying code managing the communication through the proxy is not dealing with the null terminator on the chunk encoded response when the connection to the proxy is being kept open? Does anyone have any experience in this area? Is the source to the emulator available so I can try and understand what is going on here?
View 8 Replies
View Related
May 20, 2010
My input is a InputStream which contains an XML document. Encoding used in XML is unknown and it is defined in the first line of XML document.
From this InputStream, I want to have all document in a String.
To do this, I use a BufferedInputStream to mark the beginning of the file and start reading first line. I read this first line to get encoding and then I use an InputStreamReader to generate a String with the correct encoding.
It seems that it is not the best way to achieve this goal because it produces an OutOfMemory error.
Any idea, how to do it ? code...
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
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
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 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
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
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
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
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
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
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'm facing an annoying problem here. My application is connected to a server that sends some data from time to time. It's some kind of eventing server. In order to receive data, I'm connecting to the server with an HttpURLConnection, retrieve the response InputStream and loop on it with the read method. The connection is always open. The distant server is cutting the connection every 5 minutes (for test purpose). When connection is closed, my application has to reconnect again. We detect a Connection Reset by Peer exception when the server closes the connection. The problem is that most of the time, I never receive the Connection Reset by Peer exception. So my application can't know that is has to reconnect and it's stucked on the read instruction. The InputStream.Read() method shouldn't always raise an exception if the connection is closed? What can I do to always detect Connection Reset by Peer exception?
View 15 Replies
View Related
Mar 2, 2010
How can you read GZIP file in Android located in the "ASSETS" (or resources/raw) folder?
I have tried the following code, but my stream size is always 1.
GZIPInputStream fIn = new GZIPInputStream(mContext.getResources().openRawResource(R.raw.myfilegz));
int size = fIn.available();
For some reason the size is always 1. But if Idon't GZIP the file, it works fine.
Using Android 1.5
View 5 Replies
View Related
Sep 16, 2010
In my android application i want to load a gzip file along with my application into device. I tried placing it in /data/data/mypackage but its not getting loaded into the device. I also tried placing in raw folder but still not working. Is there any way that i can get this done?
View 1 Replies
View Related
Jan 6, 2010
I would like to show a custom input field (specifically, one containing only 9-0 and two extra buttons containing decimal separator (, or .) and a delete button). I could create a custom IME, but (as far as I know) that would have to be set by the user as the system-wide input method. Is there a way to implement an input method and bind it to a specific input field?
View 1 Replies
View Related
May 28, 2010
I have started to work with the WebView component of Android Platform, but the API to load data to the component is confusing me, because it includes a parameter with a encoding. In both methods: public void loadData (String data, String mimeType, String encoding); public void loadDataWithBaseURL (String baseUrl, String data, String mimeType, String encoding, String historyUrl); you have to specify an encoding. In both cases, the API documentation says that is is the encodign of the data (data parameter). Well, as know, if you provide data as a String object, the String is internally stored in UTF-16 (unicode). To get a String object from a external source, you need to specify the external source encoding to convert it to UTF-16 and get the String internal representation (String(byte[] data, String encoding)). So, at this moment, when you have an String instance, everything from the original source has been converted to UTF-16. So, why do you need to specify an encoding if you are providing the data as a String object?
I don't know the internal implementation of WebKit, but let's suppose that, WebKit has a method, to render a source, providing as content an InputStream and a default encoding. Well, as I know, when you process a HTML page, you use the default encoding to read the HTML characters, and if you find a <meta> tag specifing a different encoding, from that moment, you have to use the new encoding to decode the characters of the HTML page. But what happens if you supply a HTML page that contains this <meta> tag: <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=ISO-8859-1"/> using one of the methods specified at the top of this post, how are you going to read ISO-8859-1 encoding from a String that it is in UTF-16 encoding? if the WebKit filtering this <meta> tags, and doesn't taking in account the encoding specified in this tag? Well, all of this is very confusing for me, because I don't understand why the API includes this encoding parameter. I also don't know if the <meta> encoding tags are filtered when the source is provided as a String? Can anyone solve my doubts?
View 2 Replies
View Related
Nov 19, 2010
I am facing a problem about encoding.
For example,
I have a message in xml format encoding is "UTF-8".
CODE:.........
Now, this message are supporting multiple language.
Traditional Chinese (big5), Simple Chinese (gb), English (utf-8)
And it will only change the encoding in specific fields.
For example (Traditional Chinese),
CODE:..........
Only "蘋果" and "橙" are using big5, "<product_name>" and "</product_name>" stills in use utf-8.
<price>1.3</price> and <price>1.2</price> are using utf-8.
How do I know which word is using different encoding?
View 3 Replies
View Related
Aug 24, 2010
I'm working on an application using the SMS apis for android. The receiving end is an embedded unit that only supports 7-bit encoded SMS and the string I'm sending consists only of symbols from this particular alphabet which makes you think that Android is going to send it encoded as 7 bit. But that is not the case.Therefore I'm searching for a way to specify what encoding to use. See below for what my code looks like today. The method gsm7BitPackedToString turns a byte-array to a 7-bit string, i.e. the string only consists of 7-bit compatible characters and is copied from the internal android api. Code...
View 2 Replies
View Related
Feb 5, 2010
What is the default encoding of android system?
View 1 Replies
View Related
Mar 15, 2010
Assume I want to write an xml resource file with a a non-europian language, say japanese, thai or chinese-What encodings can I use and what do I have to to to both the xml header and the Writer to makes these work - Also is there an easy way to map a Locale into acceptable encodings
View 4 Replies
View Related
Apr 8, 2009
I've added one new feature to Opencore & Framework to let them support encoding qcelp. But I found that Eclipse cannot figure out this new feature, e.g.
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_QCELP);recorder.setAudioEncoder(MediaRecorder.AudioEncoder.QCELP);
Eclipse now does not think RAW_QCELP & QCELP as legal symbols. So, what should I do to update the SDK to pass though this issue? Overwrite its system.img, boot.img or some *.jar packages?
View 3 Replies
View Related
Oct 27, 2010
I am trying to stream mp3 stream from my local http server indeed hosted on my phone to android media player.When local server gets the new socket , it starts writing some http headers followed by mp3 stream. but mediaplayer socket is throwing "Broken pipe" exception.Wat may be the issue causing this.
View 1 Replies
View Related
Aug 26, 2009
I have two text file, both of them contains Chinese characters, one text file is saved using ANSI encoding, but this file's Chinese characters can not be displayed by htmlviewer on the phone. The Chinese characters in another txt file saved using unicode can be displayed ok by htmlviewer. Do you have any suggestions on this, does Chinese characters using ANSI encoding supported?
View 3 Replies
View Related
Aug 9, 2010
I'm trying to rip some DVDs from my collection and get them on my phone for a trip that I will be taking. I just tried to convert one 480x880, 30fps, Constant Bitrate @ 100%, MP4, x264. IDK what went wrong but it wouldn't play from my phone but played fine on my Mac. Does anyone have any suggestions?
View 4 Replies
View Related
Jun 3, 2012
I don't know why but some emails I sent aren't showing properly. If I write something like: "hey, what have you planned for tomorrow"?
It's delivered like this:
=?UTF-8?B?5pS25Yiw5LqM5pak5Zub55uS6ZOB6KeC6Z+z?=
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64[code]...
At first I thought it was because of some ROM so I made a clean install of Gingerbread.This didn't fix it so I updated to ICS. Not even changing my written language from Chinese to English worked.
View 7 Replies
View Related
Aug 10, 2010
I'm able to get AC3 5.1 @ 640kbs to work with my 720p mkv files but the playback skips about every 5 seconds. Other then that It looks and sounds amazing! I've tried encoded to 5.1 FLAC and AAC but it doesn't play at all. Are there any encoding experts out there?
View 1 Replies
View Related
Jul 3, 2012
I have LG P970 Optimus black. I know this problem is about a lot of devices and a lot of regions. We are using latin alphabet with some special characters. like "ı, ş, �, ğ, �.." when someone sends me a text message with this characters,
It is normally shown in cm7 and its based roms.
It is normally shown in lg roms which are released for turkey
but it is shown like one space in different lg roms.
For fixing it, what can i do. Is it about message apk? or about some libs?
View 1 Replies
View Related