I need your advice or ideas regarding my problem. The app I'm working on needs to display an image and text from two separate web services. The first web service (image) returns a base64 encoded string and the last web service(text) returns a plain json response.
Some samples I found on the web is that they only use one service to display the record with the the string url of image something like this:
[{"id":"1","version_name":"Alpha","description":"","version_code":"1.0","api_level":"1","image":"http:\/\/www.test.com/img/cupcake.jpg"}]
But in my case, the client has given me two separate calls to view the data (details) and image:
[{"id":"1","version_name":"Alpha","description":"","version_code":"1.0","api_level":"1"}]
for image Base64 String result (SAMPLE):
"iVBORw0KGgoAAAANSUhEUgAAAGQAAABfCAYAAAAeX2I6AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxIAAAsSAdLdfvwAAEc8SURBVHhezb13dBzHmT3qc37nvV1bXq+9tvfn9Xpt79q78tpWdJAsKllWJsWcwRyRc2QQgyiJogIpkiIJEDkMcmLOOSeJOZPIwOQ8gxkAvO9+NWhwBIE0Kck+7497uru6urr7u/Wl6urub+g6SpDfVYIcVHBZhbxblfeMXHCJUuR0ViC7s0ohE9VIJ1az/DbKWFahkMFj1nI7u6sCeV21yL1VhbLOYuhQjOqOXNShAFbWcHV9AheXdmQpOJANJ5ceLt08i8BxK5/7ctU+B/e5b+XB2ZlD5MLZlUVksp1suG6xjOsCtzo+B/ZbRTymGLauPK6znVuFatsh52c9gQNFsHUSXflcl3Pksb1cIl+16brF9rpKed5CgudUbRSptgLtFdwznDze0VmAr0RINoWbyZvIoNBzb1HAJCansxzZt8qR21V9G6ybc6usBxm
To display this in a listview, how would I display them at the same time? How would you create a workaround for this?
I would truly appreciate your help. Thanks.
Related
I want to show data in a sensible form for my movie database app. The website I am using to extract data from is www.omdbapi.com. I have already created a code that extracts the title and year of the movies and displays it in a ListView form which contains items that are all clickable to another activity. I would like each activity that the ListView item clicks to to display the movie information under different headers etc.
I have been stuck on this issue all day. I'm new to coding and have no clue what most processes are called etc. Im not asking for the entire code, just instructions on what to do because I am stumped. I would be very very grateful.
Thank you.
Depending on the format the response is formatted you would either use (probably) an xml parser or a JSON parser and grab the info between specific xml tags or the specific keys within the JSON output.
There are thousands of examples of both methods. If you can get the title to display, then you already know how to get the other elements.
I have an application which fetches data from a MySQL database. That data contains image urls which I have managed to implement an imageLoader class to display the image using the images url. I have however hit a dead end when it came to displaying an image which is contained in the text fetched and is wrapped in the <img> tag. Kindly assist me in displaying an image contained in the post content. Below is a sample of the data fetched.
This is a sample post, you may choose to continue reading or not. <a href='http://website.com/post'><img src=' http://website.com/post.jpg'></a>
This is a sample post, you may choose to continue reading or not
From the above text, How do I display http://website.com/post.jpg in an android imageview?
If all you want to do is extract the image url from the text returned from the database something like the following will suffice:
int start = s.indexOf("<img src='")+10;
int end = s.indexOf("'",start);
String url = s.substring(start, end));
where s is the string returned from the database
I finally got a perfect solution for my problem. Using jsoup, I am able to get the HTML tags in my string and also I am able to replace the entire HTML segment with whatever content I want. Thanks for your input and hope this answer will help someone sometime.
I want to show a picture in my app but the json data from the server looks like this
"property_plans":["~~~http:\/\/irandng.com\/melk\/wp-content\/uploads\/2015\/07\/plan4.jpg~~~http:\/\/irandng.com\/melk\/wp-content\/uploads\/2015\/07\/plan3.jpg~~~http:\/\/irandng.com\/melk\/wp-content\/uploads\/2015\/07\/plan1.jpg~~~http:\/\/irandng.com\/melk\/wp-content\/uploads\/2015\/07\/plan2.png"]
How can I show the pictures? I have a problem with ~~~. How can I fix it?
You can split the string using the aptly named function https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
I created an android test app with camera interface in which I want to save a text message and image file as one object. I am able to enter message, call the camera,take a picture and also populate the image in the image view on the app. Now I want to save them as one single record/object so that I can transfer it over network using protocol such as ftp. How to save image file and text together as one single file/object? Could someone please tell me how to do that. Thanks in advance.
There are lots of possibilities, and it depends to some extent on what will be consuming the file after it is transferred. You could, for instance, simply serialize the string and the image data using a DataOutputStream wrapped around a FileOutputStream. As a fancy version of that, you could define a class to contain the text and the image, have that class implement Serializable, and serialize it to a file. Alternatively, you could serialize the image data as a base-64 string and then put the text and the base-64 image data into an XML document or JSON string. Other approaches are also possible.
If you provide more details about what kind of process will consume this file after it has been transferred, perhaps we can provide more focused suggestions.
All I want to do is to send a URL String into my RESTFUL web service with some kind of code like this
URL someURL= new URL("http://myWebService:port/service/"+CharSequence.getText());
Its all going well until I found error with space character in my URL. I found some solution about replacing the space character with %20 which is I already defined with something like this :
URL someURL= new URL("http://myWebService:port/service/"+CharSequence.getText().replace(" ", "%20"));
Everything, again, seems going well until i found that the replace(Char oldChara, Char newChara) function can only replace ONE space character, and not two.
For brief example when I send the CharSequence.getText() with values "We won" there will be no error, but when I change the values into "We won the battles" there will be an error issuing that there are some illegal character sent to my RESTFUL web service.
Any kind of answer will come up with my great thanks and big salute
~Regards~
Use replaceAll instead of replace.
Although, you should really be doing proper URL encoding. You can use URLEncoder.encode
for example.