Having trouble downloading an image when using the Android Query (aQuery) library to download image that has redirect:
Using url https://api.twitter.com/1/users/profile_image?screen_name=scottyab&size=bigger
in web browser redirects to
https://si0.twimg.com/profile_images/2467461312/5rab7gapdrnd84b6nflx_bigger.jpeg
Here's the activity code for doing the async image call:
aq.id(R.id.twitter_image)
.progress(R.id.twitter_image_progress)
.image(getTwitterProfileUrl(twitterName),
true, true, 0, R.drawable.no_profile_placeholder,
new MyBitmapCallback());
Getting an internal AQuery error 101 network error. This there an option to enable AQuery redirect? The URL returned in the call back is the original url not the redirected URL. Specifically finding this an issue on Android 2.1
Android-Query doesn't appear to handle redirects currently, and it looks like it would require a code change to support them.
I took a look at the AQuery source code, and I think this is the code to do the request: https://code.google.com/p/android-query/source/browse/trunk/src/com/androidquery/callback/AbstractAjaxCallback.java#1483
Here is how it could be implemented to follow redirects:
Httpclient redirect handler
It would have to handle codes >= 300 and < 400 to handle redirects.
Related
Apparently everything after the hash is called "encoded fragment". The Uri.getEncodedFragment() returns this string.
My use case is this. Given an URL:
url = "https://first/#/second"
If I do a:
webView.loadUrl(url);
The WebView removes everything after the hash symbol, making the request with the modified URL:
"https://first/"
Any ideas on how to pass the full URL in the request?
EDIT:
I think this is related to a well known redirect problem:
URL Fragment and 302 redirects
Anyone has any solution for Android?
I just tested AQuery's image loading based on this tutorial. It works well, when I use on an URL like example.com/xy.jpg. But what if I want to load an image that is displayed by a page (for example a php page)?
If my url is like this: example.com/showimage.php, I get a message of this: SkImageDecoder::Factory returned null.
Does AQuery support deferred image loading?
Yes it can if the PHP page redirects to a valid image.
I have a webview in Android app and load my webapplication. I am listening the page navigation using ShouldOverrideURL method and do some operation. I want to do specific operation when the URL method type is GET or POST. I cannot use PostURL method here as I load only one home URL.
It looks like shouldOverrideUrl is only called during GET requests: Android - how to intercept a form POST in android WebViewClient on API level 4
If you want to do a specific operation during a POST operation for a particular URL, you want to extend WebView and override WebView#postUrl(String url, byte[] postData).
In a phonegap-android application i want to open an external link within the application.
For this i used a plugin childBrowser and it works fine.
But the external link is taking time to load for which i want to show a wait/loading message.
I also tried to open the external link through ajax-call, updating the div with the response page. and until reponse is not received i am showing a loading message but the problem with this approach is that page loses its styles and other structure.
I guess this is because i am putting entire external page inside the div tag which cannot render the entire page as the browser can do it.
Code snippet looks like-
<script type="text/javascript">
function loadPage(url) {
var xmlhttp = new XMLHttpRequest();
// Callback function when XMLHttpRequest is ready
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState === 4){
if (xmlhttp.status === 200) {
document.getElementById('container').innerHTML = xmlhttp.responseText;
}
}
};
xmlhttp.open("GET", url , true);
xmlhttp.send();
}
</script>
How can i achieve this, can I override childBrowser?
Also
if i want to open the page in applications' web view then how can i achieve the same for web-view.
EDIT: As per Same origin policy one cannot call to a outside domain using xhr request.
Okay understood. i checked in browser and got expected error: 'XMLHttpRequest cannot load'
But then how does it shows/opens the url in mobile?
Ofcourse the page is not fully functional and thats my original issue.
i would post this as a separate question, but its related to my original question
Thanx.
Any hints/suggestions would be great.
I take the response from an HTTP connection in the form of string and show that to webview like this:
WebView engine = (WebView)findViewById(R.id.webview);
engine.loadData(endResult, "text/html", "UTF-8"); /*endresult is string*/
I actually get a response that contains the google page (google search result direct from google.com).
The loadData method works well i.e it shows the web page but when I click on one of the links on that page it shows "page not available" and said that "xyz link might be temporarily down or it may have moved to permanently to a new web address".
this happens for all links accept the first present link on that page. i.e it shows correct page from first link on that page but fails for others..
I noticed that OSes prior to 2.3 failed to follow links if setHorizontalScrollBarEnabled and setVerticalScrollBarEnabled are set to false.
try to use loadDataWithBaseURL of the WebView class
I would avoid using engine.loadData - it seems to cause all sorts of crazy problems.
Use engine.loadDataWithBaseURL instead, and pass the base URL of where the content exists. I would think that the content you are loading is using relative paths in it's HTML so it's looking inside your app resources. By specifying the base URL you get around this problem.