httpurlconnection

BindProcessToNetwork not working on a specific device

微笑、不失礼 提交于 2021-01-28 05:07:13
问题 I have an app that's custom built for a client and not available in the Play Store that basically makes some network calls when it detects that the device is connected to their WiFi. This should happen even if it has no internet connection, every request that the app makes is to a local address. The problem comes with the new batch of tablets that the client has purchased (Galaxy Tab Active 2, Android 8.1.0, Build number M1AJQ.T395XXU3BRJ5), which will always prefer a connection with internet

Google Safe Browsing API v4 - Empty response

筅森魡賤 提交于 2020-07-22 06:27:44
问题 Despite that I check a malicious URL (http://fileserver03.com), empty response returns from Google Safe Browsing API v4 . Here is the code I have tried: String postURL = https://safebrowsing.googleapis.com/v4/threatMatches:find?key=API_KEY String requestBody = "{" + " \"client\": {" + " \"clientId\": \"twittersentidetector\"," + " \"clientVersion\": \"1.0\"" + " }," + " \"threatInfo\": {" + " \"threatTypes\": [\"MALWARE\", \"SOCIAL_ENGINEERING\"]," + " \"platformTypes\": [\"ANY_PLATFORM\"],"

Android with Kotlin - How to use HttpUrlConnection

∥☆過路亽.° 提交于 2020-06-12 05:02:26
问题 I´m trying to get data from a url inside an AsyncTask but I get an error when creating a new instance of HttpUrlConnection . Something like this on Java URL url = new URL("http://www.android.com/"); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); try { InputStream in = new BufferedInputStream(urlConnection.getInputStream()); readStream(in); finally { urlConnection.disconnect(); } But I keep getting the error shown below. class GetWeatherTask : AsyncTast<Void, Void,

what makes Jsoup faster than HttpURLConnection & HttpClient in most cases

拜拜、爱过 提交于 2020-05-16 05:58:25
问题 I want to compare performances for the three implementations mentioned in the title, I wrote a little JAVA program to help me doing this. The main method contains three blocks of testing, each block looks like this : nb=0; time=0; for (int i = 0; i < 7; i++) { double v = methodX(url); if(v>0){ nb++; time+=v; } } if(nb==0) nb=1; System.out.println("HttpClient : "+(time/ ((double) nb))+". Tries "+nb+"/7"); Variable nb is used to avoid failed requests. Now method methodX is one of : private

Android: Too many open files error

孤者浪人 提交于 2020-05-11 05:38:30
问题 I have the following operation which runs every 3 seconds. Basically it downloads a file from a server and save it into a local file every 3 seconds. The following code does the job for a while. public class DownloadTask extends AsyncTask<String, Void, String>{ @Override protected String doInBackground(String... params) { downloadCommandFile( eventUrl); return null; } } private void downloadCommandFile(String dlUrl){ int count; try { URL url = new URL( dlUrl ); NetUtils.trustAllHosts();

Jersey Equivalent to HttpUrlConnection

放肆的年华 提交于 2020-04-30 10:19:13
问题 So I am trying to add a cookie to a connection. In HTTPUrlConnection, I do the following: HttpURLConnection con; String cookieString = null; con = ((HttpURLConnection) new URL(appUrl).openConnection()); String cookieString = formatCookies("session", userCredential); con.setRequestProperty("Cookie", cookieString); ... I want to do the same in Jersey. So far I have the following: WebTarget wt = client.target(appUrl).path(path); wt.queryParam(..., ...) .request(...) .cookie("session",

Http URLConnection wait for inner request

我是研究僧i 提交于 2020-03-23 12:32:12
问题 I am working on a crawling project. When I do a simple URLConnection connection to the website as shown in below: URLConnection conn = new URL(url).openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); The method returns the HTML body correctly. However, the website makes inner requests for some fields. For example, the website fetches the total number of users from a different web service. In the web browser, the total number of users

How to fix 'Cleartext HTTP traffic to x not permitted'

梦想的初衷 提交于 2020-03-03 03:43:53
问题 I'm trying to make a post request to an http server, but when I try to get an input stream I get the error java.io.IOException: Cleartext HTTP traffic to x not permitted I've already tried putting android:usesCleartextTraffic="true" in my manifest, as well as making a network security config and setting the android:targetSandboxVersion to 1 app/src/main/res/xml/network_security_config.xml <?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted

How to fix 'Cleartext HTTP traffic to x not permitted'

…衆ロ難τιáo~ 提交于 2020-03-03 03:43:42
问题 I'm trying to make a post request to an http server, but when I try to get an input stream I get the error java.io.IOException: Cleartext HTTP traffic to x not permitted I've already tried putting android:usesCleartextTraffic="true" in my manifest, as well as making a network security config and setting the android:targetSandboxVersion to 1 app/src/main/res/xml/network_security_config.xml <?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted

How to fix 'Cleartext HTTP traffic to x not permitted'

谁说我不能喝 提交于 2020-03-03 03:43:06
问题 I'm trying to make a post request to an http server, but when I try to get an input stream I get the error java.io.IOException: Cleartext HTTP traffic to x not permitted I've already tried putting android:usesCleartextTraffic="true" in my manifest, as well as making a network security config and setting the android:targetSandboxVersion to 1 app/src/main/res/xml/network_security_config.xml <?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted