Android :: How To Load A Typeface From An Input Stream?
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
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
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
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
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
Jun 14, 2010
I've been trying to stream videos on my phone--not Youtube, and I just can't get the pages to load. I've been trying to watch stuff on ATDHE.net using Dolphin browser HD. Can the evo not load content on this site, or is it the browser?
View 8 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
Jul 13, 2010
My friend stream won't load any info on my home page and when I go into it via the main menu it 'force closes'. Any offers?
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
Jul 13, 2009
I've learned that to set typeface needs font to be under asset folder how to dynamically load the ttf file to be used in code? or maybe how in runtime to add ttf file into the asset folder? is there any solution for this problem?
View 3 Replies
View Related
Oct 30, 2009
I want to make a content provider for font file. But I can not find any way to return a Typeface from Cursor. According to SDK reference, Matrix Cursor sounds like a solution, but it doesn't support any object except String,Long,Double,Short,Flow.
View 4 Replies
View Related
Jun 10, 2009
I want to apply a non-native font to widgets in my app. This is working fine for TextViews and Buttons, which have a set Typeface method. The code below works just great for my button:
Java: Typeface face = Typeface.gratefullest(getAssets(), "fonts/ my_font.ttf"); play Button = (Button) findViewById(R.id.play_button); play Button.set Typeface(face);
But I just can't seem to figure out how to apply the font to a Spinner.
View 2 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 10, 2009
The Typeface can not read a TTY font from external file. I just want to know why. Why this feature is denied even in 1.5r1? And have any plan to open the feature?
View 6 Replies
View Related
Mar 23, 2009
Does anyone know how to construct a typeface object from a file? Say i have a .ttf file on the SD card, how do i load it into my app?
View 5 Replies
View Related
Jan 12, 2010
I've created a custom Typeface by adding a TTY file to the assets folder, and I use the set Typeface method to apply this font to each of the text views, and everything works great. The only problem I have, is that I write a lot of code lines in order to apply this font to all text views. Is there a way to make this font the default font in my project, or to apply it to all text views at once?
View 2 Replies
View Related
Sep 16, 2010
I've got 2 problems with the Typeface.create(...) method :
- the javadoc for this methods say : "Create a typeface object given a family name, and option style information. If null is passed for the name, then the default font will be chosen". However if I use for example : Typeface.create(null, Typeface.ITALIC), it does not compile, with the following error : "The method create(String, int) is ambiguous for the type Typeface". This is because there is 2 different methods : create(String, int) and create(Typeface, int). I guess there is a problem with the API here :(
- italic does not work with sans serif. For example if I use Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC), the text will not be in italic. Bold works fine. Serif works fine with both bold and italic.
View 6 Replies
View Related
Aug 30, 2009
The default marquee scroll (i.e., three scrolls of text when list item is selected) in my application's List View works when the typeface is set to Typeface.NORMAL but not when set to Typeface.ITALIC. Is the marquee scroll implemented for TextViews with the ITALIC typeface?
View 2 Replies
View Related
Sep 7, 2010
I need to change the dialog's typeface to use an external font that supports some unicode characters. Unfortunately, there is no AlertDialog.setTypeFace() method available.
View 2 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
Oct 22, 2010
I have been assigned the task to use an android tablet to run a single app in an enterprise setting. Ideally, when one switches on the tablet this app should be loaded perhaps during startup and the user need not step out of this app. The app logic itself is rather easy but I am wondering if it is at all possible to load a single app during load and not allowing the user to step out of it.
View 2 Replies
View Related
Sep 4, 2010
Is it possible to load a layout XML at runtime and load into activity?
In my app, I have various types of data like Person, Company, City, etc; The requirement is to dynamically load the layout, find views by tags (property names like Person.name, Person.address) and then fill in data. For example, if user has selected an object of type Company, we want to load a company.xml layout, inflate it and then associate various properties (company name, company slogan, city, address, revenue) to tagged views. One possibility I see here is - each view in the layout will be associated with property-name as tag and then appropriate data will be loaded in appropriate views.
What should be the best design you would recommend?
View 1 Replies
View Related
Nov 26, 2010
Anyone know of a good App that will let you change the style/color of the typeface on the X8? Wife has an X8, but is having problems reading the white text against the wallpaper pic. Tried various pics for wallpaper, but she is looking for a black type face to make things easier. Can't seem to change the color or style through settings, or is she missing something?
View 7 Replies
View Related
Dec 30, 2009
As the title implies, I am looking for the typeface for the clock when you enter in the pattern. Does anyone know of it offhand or know where I can find it in the source code?
View 1 Replies
View Related
Sep 28, 2009
I try to display italic text in a text view. I use the method TypeFace.defaultFromstyle(TypeFace.ITALIC) but it doesn't work, the style of the text is not set to italic. If i call the get Style() method on the return of defaultFromstyle() it returns 0.
View 1 Replies
View Related