Android :: How To Get Input Stream Of An Xml File Which Is Placed Under /res / Xml?
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 Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Android :: Getting File Size Before Input Stream
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 Replies!
View Related
Android :: Resetting A HTTP Input Stream?
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 Replies!
View Related
Android :: IO Exception While Reading From Input Stream?
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 Replies!
View Related
Android :: Chunked Encoding - GZIP Input Stream
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 Replies!
View Related
Android :: Buffered Input Stream Buffer Size
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 Replies!
View Related
Android :: Parsing Speed / Reading Vs Converting Input Stream To String?
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 Replies!
View Related
Android :: Change Internal Buffer Size Of Data Input Stream
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 Replies!
View Related
Android :: Why Is My Input Stream Not Working In Android?
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 Replies!
View Related
Android :: Use An Audio File As Input To Speech Recognition?
Is there a way to use an audio file as input to speech recognition? If not, is this feature expected in the foreseeable future? A separate question (and this is going to sound ridiculous, but it might actually be okay for a joke app I'm thinking about): Would it be possible to play audio out of an Android handset, while at the same time having a recognizer listen to it via the microphone? (Guess I could just try it.)
View Replies!
View Related
Android :: Deleting Files Created With File Output Stream
I'm developing for the Android platform. My app creates a temp file with a simple call to: FileOutputStream fos = openFileOutput("MY_TEMP.TXT",Mode); It works fine because I can write to it and read it normally. The problem is that when I exit from the app I want to delete this file. I used: File f = new File(System.getProperty("user.dir"),"MY_TEMP.TXT"); f.delete() But it always returns false and the file is not deleted. I have tried File f = new File("MY_TEMP.TXT"); f.delete(); And it does not work either.
View Replies!
View Related
Android :: Method To Capture Video To File Or Stream From OpenGL App?
Does anyone knows some convinient method to capture video to file or stream from OpenGL app on Android device? For example, can we capture video from a view, opengl view? I just found out the following: 1) We can get frames using glReadPixels. (No video on this step?) 2) MediaRecorder can encode video, but how can we provide it our raw source, if possible? 3) Any working ports of ffmpeg(for example) or other encoding libraries? There are some tutorials of portng ffmpeg to use withing NDK. So, having raw frames and working port of ffmeg we can create video? Any issues on this step? Anyone managed to port any encoding library successfully? What components do I need from ffpmeg?
View Replies!
View Related
Android :: Reading Binary File From Sdcard Using Stream Classes
Can anybody have any idea how to read a binary file which resides in sdcard using Streams, like Inputstream, CountingInputStream or SwappedDataInputStream?I am using these three streams to read a file which is currently in the Resouces folder, but now i want to move that file in sdcard but I cannot change these stream because I have done so much work on it and I cannot roll back my work.i am doing it this way but its giving me FileNotFoundException.
View Replies!
View Related
Android : Streaming Audio/video Can't Stream A Rtsp File
I want to stream a media file on web, and android developer website has said that MediaPlayer.setDataSource() can set the data source (file-path or http/rtsp URL) to use. But I got an error in both G1 device and emulator when streaming a rtsp url file: Command PLAYER_PREPARE completed with an error or info PVMFailure error(1, -1). Does anyone know what is this error, or anyone knows where can I get the error description (1, -1) means? the code can work successfully when playing a audio/video file or streaming a http protocal sudio/video file, but can't stream rtsp protocal file. Is android not supported rtsp streaming?
View Replies!
View Related
Android :: Analog To IOS Core Audio / Audio File Stream Services?
Is there an Android equivalent to the iOS Core Audio / Audio File Stream Services? I need to be able to read audio bytes from a network and feed them to the audio system under my control, so I can do my own timeouts / reconnects / range requests / etc. without interrupting the audio playback (since the system audio thread would be playing audio already enqueued). It seems that MediaPlayer doesn't give me this level of control. Is there a lower-level framework that does, either in the SDK or NDK?
View Replies!
View Related
Android :: Input Field With Custom Input Method
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 Replies!
View Related
Android :: Attaching Txt File While Email From Internal Package File Storage
I am successful in creating file using openFileOutput(). and can read the file using openFileInput(). I am able attach file from external storage sdcard while emailing the same using getExternalStorageDirectory as sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/ zibra.txt")); But while trying to attach file from the openOutputFile stored area using sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ getFilesDir() + "/zibra.txt"));, resulting emptied file emailing. My file is stored in "/data/data/com.example/files/zibra.txt". what is going wrong in it? CODE:...................
View Replies!
View Related
Android :: PackageManage - Couldn't Copy Package File To Temp File
We are suddenly unable to install our app on G1 developer phones with 1.6. Works perfectly on emulator. When installing the app we get: Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE Please check logcat output for more details. Launch canceled! And logcat: PackageManage: Couldn't copy package file to temp file. What does this mean? We checked that there is actually room enough on the phone.. We tried reverting the code to a revision that worked previously, but are getting the same error.
View Replies!
View Related
Android :: Unable To Play File When Set Data Source To Sd Card File
I am trying to play file which is stored in SDCARD in emulator. I have Linux O/S. So i need to provide command in run configuration. I am providing following parameter. -sdcard /usr/android/sdcard/mysdcard.iso -audio oss [i] The following is my code to play file. try { mMediaPlayer.setDataSource("/sdcard/test_cbr.mp3"); mMediaPlayer.prepare(); // Giving error. mMediaPlayer.start(); }
View Replies!
View Related
Android :: Is It Efficient To Use Text File Or XML File To Store Static Data
I have some reference data in a text file (~5MB) that I want to use with might android application.The file is of the format: 1|a|This is line 1a 1|b|This is line 1b 2|a|This is line 2a 2|b|This is line 2b 2|c|This is line 2c What I want to know is the most efficient way (less memory, fast, size etc.) to use this file within my application. a.) Should I save the file as a raw resource and open and read the whole file whenever I need a certain line. b.) Should I convert the file to XML and use XPath to query the file when ever I need to look up a value <!--sample XML --> <data> <line number="1"> <entry name="a">This is line 1 a</entry> </line> </data> c.) Should I just copy & paste the whole file as a static string array in the application and use that. [EDIT] I will also need to search this file and jump to arbitrary keywords e.g. "line 1a".
View Replies!
View Related
Android :: Resize Large Bitmap File To Scaled Output File
I have a large bitmap (say 3888x2592) in a file. Now, I want to resize that bitmap to 800x533 and save it to another file.I normally would scale the bitmap by calling Bitmap.createBitmap method but it needs a source bitmap as the first argument, which I can't provide because loading the original image into a Bitmap object would of course exceed the memory (see here, for example).Is there a way to read a large image file with 10MP or more and save it to a new image file, resized to a specific new width and height, without getting an OutOfMemory exception?I also tried BitmapFactory.decodeFile(file, options) and setting the Options.outHeight and Options.outWidth values manually to 800 and 533, but it doesn't work that way.
View Replies!
View Related
Android :: Private Signed Keystore File From Previous Apk Release File
I have created the private signed keystore file using eclipse and i have released the apk files in android market website. after some days we got some issues from users and we have fixed the issues but i don't have private signed keystore file. while making the apk file i need to use previous version release used private signed keystore file. Is there way to get private signed keystore file from previous apk release file?
View Replies!
View Related
Android :: How To Get Stream Of Audio
I used Class MediaRecorder to play mp3 file, the source like this: CODE:............. It runs no problem. But I want to get the stream,and write the byte array to the stream, let mick sound the refreing voice. by use java source I can did that. the source like this: CODE:............. You know,Android SDK don't include the class SourceDataLine(package javax.sound.sampled).
View Replies!
View Related
Android :: How To Stream Video
I want to play video file that exists in one of my servers. I am using MediaPlay and VideoView classes and it works fine but the problem is that the video start to play only when it finished downloading the whole file. How can i stream it, meaning play the video while it continues to download?
View Replies!
View Related
Android :: Apps That Will Stream From A NAS
pretty self explanatory. Any apps that will stream video directly from a NAS? It's a synology, and I'm aware of DS photo and DS audio. I use them both, but I'm not using the software to convert all my videos just so i can play them on my Eris. Obviously the NAS is standalone, so I won't have a PC on (hence no tversity, twonky, orb, playon, etc). I wish mVideoPlayer did this, i'd be in heaven. I guess if such an app doesn't exist... is there anything that can play video from a DLNA/uPnP device over both 3g and wifi? Either way, still looking for a solution to streaming video on android heh.
View Replies!
View Related
Android :: VLC Stream And Convert
Has anyone tried the app VLC Stream and Convert? VLC Stream & Convert v0.4.28 Application for Android | Multimedia. It looks promising as a streaming option but I can't work out how to set it to actually stream videos to the phone. It's working as a remote (so VLC is working correctly) but there are no instruction available on how to configure streaming.
View Replies!
View Related
Android :: App Works To Stream When Using DI.FM
I just got back from the Verizon store. I was checking out the Droid... I popped open the browser and went to DI.FM. Digitally Imported - Addictive Electronic Music I tried all 3 public streams (MP3, Windows Media, AACPlus), and nothing. I asked the data tech guys at the counter and they said there might or will eventually probably be a app that will work with DI.FM. So anyone checked into this? Anyone gotten DI.FM working? I'm especially interested to see if I can get the premium subscriber channels to work. The phone is pretty damn sweet and right now the only thing holding me back is the fact I can't stream my favorite internet radio station. According to the specs of the Droid, it supports AACPlus streams. This is big! Currently it's next to impossible to stream AACplus encrypted streams on windows mobile.
View Replies!
View Related
Android :: Stream Music To Ps3
I'm using allshare atm to show pictures, mp3's and movies on my ps 3. But, I would like to beable to stream music from pandora or...radiotime. That way I can use my reciever and suround speakers to listen to the music. I was looking for an app...I found imediashare, but it looks to share files just like allshare. I'd rather not go out and buy bluetooth speakers in multiple rooms in the house..does anyone know of an app that will do this ?
View Replies!
View Related
Android :: Way To Stream Vedio From An URL?
Today for one of my app (Android 2.1), I wanted to stream a video from an URL. As far as I explored Android SDK it's quite good and I loved almost every piece of it. But now that it comes to video stream I am kind of lost. For any information you need about Android SDK you have thousands of blogs telling you how to do it. When it comes to video streaming, it's different. Informations is that abundant. Everyone did it it's way tricking here and there. Is there any well-know procedure that allows one to stream a video? Did google think of making it easier for its developers?
View Replies!
View Related
Android : Using To Stream Multimedia From Your PC?
I'm mainly interested in the video side of the equation. It seems the industry standard is DLNA. As the PC can function as a DLNA server, does one require an DLNA player application from Market? Windows 7 has a new share function which allows the PC to act a media server. How does one go about viewing the videos on the Android device? Let's hear what you are using!
View Replies!
View Related
Android : Is There A File Picker Widget For Custom File Formats
I'm writing a bitmap editor. Each document consists of about 3 bitmap layers and documents are, at the moment, saved as a custom file with a .bme extension. These files can be converted to standard jpg/png files by rendering each bitmap on top of one bitmap and saving the latter. I need some way for the user to be able to select .bme files they've created already. Is there anything in Android that can make this easier for me? The only option I can see is to write an activity that creates a list view and write a list adapter that looks for .bme files on disk i.e. a copy of the standard "Media Gallery" app that works for my .bme files. The list adapter will either have to generate a thumbnail preview of the image to show to the user or I'll have to package such a preview in the .bme file when they're created. This is the only option I can think of. I thought I'd ask in case there is more Android friendly way of doing this. For example, can you add custom file support to the "Media Gallery" app?
View Replies!
View Related
Android : File() Parameters Used To Download File In Phone?
In Reference to this android file download problem http://stackoverflow.com/questions/576513/android-download-binary-file-problems Can anyone explain what does this line mean in the code FileOutputStream f = new FileOutputStream(new File(root,"Video.mp4")); And what does it mean by the parameter root within the File(). Do I need to specify the root path to save the file? if it is the case then how do we specify the root path in android. Code...
View Replies!
View Related
Android : How To Open A File Browser To Upload A File
I'm a novice user writing my first android application. I have the need to upload a file to a webserver from the device. I googled enough before joining this forum and not at one place did I find a suitable solution. I would like to know how to launch the file browser when user clicks on the "Browse" button to upload a file.
View Replies!
View Related
|