httpurlconnection

How to stop HttpURLConnection connect on Android

瘦欲@ 提交于 2019-12-17 10:59:25
问题 I use AsyncTask to connect an URLPath as below code. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.left_list); Button btn = (Button)findViewById(resid); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //how to stop connect } }); new Connecting().execute(); } class Connecting extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { super.onPreExecute();

IOException: “Received authentication challenge is null” (Apache Harmony/Android)

一世执手 提交于 2019-12-17 09:19:37
问题 I am trying to send a GET via Android's HttpURLConnection (imported from org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection ), and upon receiving the response, an IOException is thrown: in doRequestInternal(): "Received authentication challenge is null" What does this error mean, and what is causing this? I am writing OAuth parameters to the Authorization header, but I do this on other occasions, too, without problems. if (connection == null) { connection =

How to modify the header of a HttpUrlConnection

邮差的信 提交于 2019-12-17 05:08:31
问题 Im trying to improve the Java Html Document a little but i'm running into problems with the HttpUrlConntion . One thing is that some servers block a request if the user agent is a Java VM. Another problem is that the HttpUrlConnection does not set the Referrer or Location header field. Since several sites use these fields to verify that the content was accessed from their own site, I'm blocked here as well. As far as I can see the only resolution is to replace the URL handler of the HTTP

How to modify the header of a HttpUrlConnection

我怕爱的太早我们不能终老 提交于 2019-12-17 05:08:10
问题 Im trying to improve the Java Html Document a little but i'm running into problems with the HttpUrlConntion . One thing is that some servers block a request if the user agent is a Java VM. Another problem is that the HttpUrlConnection does not set the Referrer or Location header field. Since several sites use these fields to verify that the content was accessed from their own site, I'm blocked here as well. As far as I can see the only resolution is to replace the URL handler of the HTTP

java.io.IOException : No authentication challenges found

拜拜、爱过 提交于 2019-12-17 05:03:31
问题 I am newbie to android and this is my first project on android. I am struggling with "authentication" problem for more than a day. I tried several options but none of them worked. Basically, I want to call a REST API and get response. I am sure that there is no problem in API as I use the same one in another iOS application. I pass authorization header but still authentication no found message is shown. I found few question on stackoverflow related to this, but some of them did not work and

java.io.IOException : No authentication challenges found

谁说胖子不能爱 提交于 2019-12-17 05:03:29
问题 I am newbie to android and this is my first project on android. I am struggling with "authentication" problem for more than a day. I tried several options but none of them worked. Basically, I want to call a REST API and get response. I am sure that there is no problem in API as I use the same one in another iOS application. I pass authorization header but still authentication no found message is shown. I found few question on stackoverflow related to this, but some of them did not work and

Getting java.net.SocketTimeoutException: Connection timed out in android

自古美人都是妖i 提交于 2019-12-17 03:01:14
问题 I'm relatively new to android development. I'm developing an android application where i'm sending request to web server and parsing json objects. Frequently i'm getting java.net.SocketTimeoutException: Connection timed out exception while communicating with the server. Some times it will work perfectly without any problem. I know this same question has been asked in SO many times. But still i didn't get any satisfying solution to this problem. I'm posting my logcat and app-server

what has been done when URL.openconnection()?

女生的网名这么多〃 提交于 2019-12-14 04:16:16
问题 I want to know what has been done when URL.openconnection(). i have done some test like this: public static void main(String[] args) { // testConnection("http://www.google.com"); testConnection("http://219.09.34.23.1"); } private static void testConnection(final String _url) { new Thread(new Runnable() { String strurl = _url; long starttime = 0; long endtime = 0; public void run() { try { System.out.println("open:" + strurl); starttime = System.currentTimeMillis(); System.out.println(

HttpUrlConnection working on api level < 11, not working on api level >11 on android

旧时模样 提交于 2019-12-14 04:13:30
问题 First of all I have two things that need your attention: 1) I tried this code on phones with api level lower than 11 and phones that are pretty high, like 4.3 or 4.4. The high api leveled phones were unable to make this code work unlike the other ones. 2)I have almost the exact code in another page, using it, it's working on all apis, only the one I'm going to show you isn't working. Thank you for listening. This is my method that makes the connection: public static StringBuilder

android HttpUrlConnection send post and params get request

↘锁芯ラ 提交于 2019-12-13 20:05:52
问题 I need a little help with sending an HttpUrlConnection from my android application. Till now I was doing this with a basic Http Client . But the problem is that when I receive a big stream from the server my applications crash with outofmemory exception. And that's why I made a research and find out that HttpUrlConnection lets me to get the stream into a pieces. So can anybody help me a little bit with sending my params and getting the response from server? The previous code that I was using