I came across a weird situation. I am trying to a develop a android app which send the user entered data to the web server. I used HttpURLConnection and wrote code. It worked a few days. Now when I try to use that app it doesn't send the data if it contains spaces in between. Also if Genymotion emulator is used then it works fine even though spaces are given. I am not getting an idea of what the problem is. What should i do now??
you simply can't write a space directly in an url.
You have to encode it via %20 ... look here In a URL, should spaces be encoded using %20 or +?
Related
I'm trying to open the following image in my android app using picasso for imageView, but it is not displaying:
https://www.mesannuairesvideos.com/uploads/file-1491574016406.jpg
However, i can open it from any browser (whether on mobile or on computer).
Am sure of my picasso method cuz it works perfectly with other urls, my problem is that images in that server are displayed on browsers and won't be shown in android applications.
Could anyone try to include this image in an android test application.
Can anyone test it for me please.That would be so helpful
Kowing that images are on a remote server.
Any help would be appreciated. thanks :)
The problem you're facing have to do with the part S from your protocol (i.e. httpS - the image you are trying to open is behind a secure connection). Picasso has a flaw dealing with secure connections. But you have workarounds. See this: https://github.com/square/picasso/issues/500
Not working for me too!
I using this code:
Picasso.with(context).load("https://www.mesannuairesvideos.com/uploads/file-1491574016406.jpg").placeholder(R.drawable.placeholder).into(holder.mPhoto);
I had this issue too. So this is how i have done
Node JS Code.
_app.get('/services/user/:photo, function(req, res){
consoles.log('Loading picture -> '+req.params.photo);
res.sendFile(_path.resolve('./upload/_profile/'+req.params.photo+'.jpg'));
console.log('./upload/_profile/'+req.params.photo+'.jpg');
});
Android code is here
Picasso.with(mContext).load(url).error(R.mipmap.ic_launcher_round).placeholder(R.mipmap.ic_launcher_round).into(viewHolder.icon);
Your url does not work try with this url https://netic-news.net/upload/_article/156.jpg
I'm waiting for your feedback!
While I know how to extract contents of a website by URLConnection and BufferedReader and get its source code, sometimes a website is itself getting data from elsewhere and showing onto the page.
e.g. I am now working on this page
http://bet.hkjc.com/marksix/userinfo.aspx?file=lucky_ocbs.asp&lang=en
and the 10 branches name and other details in the table in the page is not in the source code of the page.
Question:
Instead of extracting data from source code, is there any way to extract wordings simply from the final text showing in a page? If yes, how could it be done?
Thanks a lot.
Yes, there is a way to extract the information from the website even if it performs some client side operations such as loading the data from an external website before displaying it. Although it'll be a very tricky solution and if you would have an opportunity to make an agreement with the website's owner and ask him to provide API to your application, I'd choose that option.
Ok, according to your question you can try to use Android's WebView to render the website first. Then just get the html content using one of the method described here. The most tricky part here is to make it in user friendly way. You have to cover a WebView with a progress bar while your app is waiting for onPageFinished callback from WebView. I'm not sure that WebView is acting properly in that case. But it's worth to try.
Short Answer: You can't.
Reason: What renders the HTML is the client side. e.g: Browsers, Chrome, Firefox, IExplore, etc... Since you don't have a interpreter for the Markup Language you are unable to get only tag content ,even the browsers download all content, this is the HTTP behavior.
Workaround: Since you mentioned that some branches are not on page, i assume it is running on client side via some Javascript, what you can do is check what client is executing and perform via code). Since your client is the app.
Also see: Jsoup
You can not extract only your wanted information without download source html. after you downloaded source, you can use jsoup to iterate to only your wanted information.
add this to your app level build.gradle file
compile 'org.jsoup:jsoup:1.9.2'
then you can download and parse source code.
String url = "http://bet.hkjc.com/marksix/userinfo.aspx?file=lucky_ocbs.asp&lang=en";
InputStream input = new URL(url).openStream();
Document doc = Jsoup.parse(input, "ISO-8859-9", url);
Elements sectionElements = doc.select("div#general-info-panel");
Elements imageElements = sectionElements.select("img[src]");
you need to convert above code block to your html page source code. you can find examples to how to use jsoup.
http://phantomjs.org/ can be used to extract a website's content after JavaScript execution. Not sure if they have an android build.
We are using some images in our app from our database. We are putting them to BLOB via encoding to base64, and then getting by decoding. The problem is, that all images we are putting from android app, we are getting normally to android app, but NULL to iPhone app. However, all images we are putting from iPhone app, getting from DB normally for both: iPhone and android app. Maybe it's not same library of Base64? Why this is happening? Any idea?
Changing library of Base64 solve my problem! If somebody have the same problem, get library of Base64 from here
I am able to parse html content using HTMLCleaner & able to populate in list view. But extracting image I ma facing problem. while I am able to get images from any web server, i am not able to get same from my local Apache http server.
I want to know the reason & possible solution.
Thanks in advance.
It seems like the phone (emulator?) doesn't have access to your local server.
Use the browser in the phone/emulator and try to access your server just to make sure if it's this problem.
If you have access, print the url and make sure everything is alright.
I am developing an app which requires JSON. I use the link https://maps.googleapis.com/maps/api/place/autocomplete/json?input=+place+&types=geocode&sensor=true&key=AIzaSyCA4LKD6QfiCrGhZjCsYiRyEGqxKOUEQBU, where place is variable where the predictions are updated for. The problem is it does not take space but works fine in the browser and not in my app. Please give me the format of how variable place should be written or how browser modifies the space given
Replace all spaces with "%20" and than make an API call.
something like
place.replaceAll(" ","%20");
Happy Coding!
Krio