HttpURLConnection with JSON on Android 9, API 28 [duplicate]How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?How do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Why does Google prepend while(1); to their JSON responses?Is there a unique Android device ID?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Proper use cases for Android UserManager.isUserAGoat()?

Why might one *not* want to use a capo?

Why nature prefers simultaneous events?

STM32 cannot reach individual registers and pins as PIC

Should I use the words "pyromancy" and "necromancy" even if they don't mean what people think they do?

Why does glibc's strlen need to be so complicated to run quickly?

How is std::optional never "valueless by exception"?

What is the name of this plot that has rows with two connected dots?

Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?

Why doesn't Starship have four landing legs?

Why did Lucius make a deal out of Buckbeak hurting Draco but not about Draco being turned into a ferret?

Is this position a forced win for Black after move 14?

Another "Ask One Question" Question

What checks exist against overuse of presidential pardons in the USA?

Is the internet in Madagascar faster than in UK?

Why can't you say don't instead of won't?

What to do about my 1-month-old boy peeing through diapers?

Term used to describe a person who predicts future outcomes

Alternatives to Network Backup

Spicing up a moment of peace

Why does AM radio react to IR remote?

What's the point of fighting monsters in Zelda BotW?

How could a self contained organic body propel itself in space

Heat output from a 200W electric radiator?

Fantasy Macro Economics: What would Merfolk trade for?



HttpURLConnection with JSON on Android 9, API 28 [duplicate]


How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?How do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Why does Google prepend while(1); to their JSON responses?Is there a unique Android device ID?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Proper use cases for Android UserManager.isUserAGoat()?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2
















This question already has an answer here:



  • How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

    6 answers



I'm trying to use HttpURLConnection in Android 9, API 28. It works on Android 8.0.0, API 26, but not on API 28.



 JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("name", name);
String json = jsonObject.toString();

URL url = new URL("http://website_link");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");

OutputStream os = urlConnection.getOutputStream();
os.write(json.getBytes("UTF-8"));
os.close();

InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("utf-8")), 8);
String line;
json = "";

while ((line = reader.readLine()) != null)
json += line;


inputStream.close();

jsonObject = new JSONObject(json);

inputStream.close();
urlConnection.disconnect();

...


I tried to use Log.d to see what code is not executed and I saw that it stops on OutputStream os = urlConnection.getOutputStream();



Do you know where is the problem?










share|improve this question














marked as duplicate by Michał Ziober, tir38, gdlmx, Matteo Baldi, Mạnh Quyết Nguyễn Mar 28 at 10:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • How is this "not working"? Crash? Unexpected behavior?

    – tir38
    Mar 28 at 2:21











  • As I wrote it stops on OutputStream os = urlConnection.getOutputStream();. That part is not executed and nothing happens, app doesn't crash, just that part is not executed.

    – user3566569
    Mar 28 at 13:09

















2
















This question already has an answer here:



  • How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

    6 answers



I'm trying to use HttpURLConnection in Android 9, API 28. It works on Android 8.0.0, API 26, but not on API 28.



 JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("name", name);
String json = jsonObject.toString();

URL url = new URL("http://website_link");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");

OutputStream os = urlConnection.getOutputStream();
os.write(json.getBytes("UTF-8"));
os.close();

InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("utf-8")), 8);
String line;
json = "";

while ((line = reader.readLine()) != null)
json += line;


inputStream.close();

jsonObject = new JSONObject(json);

inputStream.close();
urlConnection.disconnect();

...


I tried to use Log.d to see what code is not executed and I saw that it stops on OutputStream os = urlConnection.getOutputStream();



Do you know where is the problem?










share|improve this question














marked as duplicate by Michał Ziober, tir38, gdlmx, Matteo Baldi, Mạnh Quyết Nguyễn Mar 28 at 10:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • How is this "not working"? Crash? Unexpected behavior?

    – tir38
    Mar 28 at 2:21











  • As I wrote it stops on OutputStream os = urlConnection.getOutputStream();. That part is not executed and nothing happens, app doesn't crash, just that part is not executed.

    – user3566569
    Mar 28 at 13:09













2












2








2









This question already has an answer here:



  • How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

    6 answers



I'm trying to use HttpURLConnection in Android 9, API 28. It works on Android 8.0.0, API 26, but not on API 28.



 JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("name", name);
String json = jsonObject.toString();

URL url = new URL("http://website_link");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");

OutputStream os = urlConnection.getOutputStream();
os.write(json.getBytes("UTF-8"));
os.close();

InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("utf-8")), 8);
String line;
json = "";

while ((line = reader.readLine()) != null)
json += line;


inputStream.close();

jsonObject = new JSONObject(json);

inputStream.close();
urlConnection.disconnect();

...


I tried to use Log.d to see what code is not executed and I saw that it stops on OutputStream os = urlConnection.getOutputStream();



Do you know where is the problem?










share|improve this question















This question already has an answer here:



  • How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

    6 answers



I'm trying to use HttpURLConnection in Android 9, API 28. It works on Android 8.0.0, API 26, but not on API 28.



 JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("name", name);
String json = jsonObject.toString();

URL url = new URL("http://website_link");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");

OutputStream os = urlConnection.getOutputStream();
os.write(json.getBytes("UTF-8"));
os.close();

InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("utf-8")), 8);
String line;
json = "";

while ((line = reader.readLine()) != null)
json += line;


inputStream.close();

jsonObject = new JSONObject(json);

inputStream.close();
urlConnection.disconnect();

...


I tried to use Log.d to see what code is not executed and I saw that it stops on OutputStream os = urlConnection.getOutputStream();



Do you know where is the problem?





This question already has an answer here:



  • How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

    6 answers







java android json httpurlconnection






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 21:20









user3566569user3566569

441 silver badge7 bronze badges




441 silver badge7 bronze badges





marked as duplicate by Michał Ziober, tir38, gdlmx, Matteo Baldi, Mạnh Quyết Nguyễn Mar 28 at 10:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











marked as duplicate by Michał Ziober, tir38, gdlmx, Matteo Baldi, Mạnh Quyết Nguyễn Mar 28 at 10:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Michał Ziober, tir38, gdlmx, Matteo Baldi, Mạnh Quyết Nguyễn Mar 28 at 10:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • How is this "not working"? Crash? Unexpected behavior?

    – tir38
    Mar 28 at 2:21











  • As I wrote it stops on OutputStream os = urlConnection.getOutputStream();. That part is not executed and nothing happens, app doesn't crash, just that part is not executed.

    – user3566569
    Mar 28 at 13:09

















  • How is this "not working"? Crash? Unexpected behavior?

    – tir38
    Mar 28 at 2:21











  • As I wrote it stops on OutputStream os = urlConnection.getOutputStream();. That part is not executed and nothing happens, app doesn't crash, just that part is not executed.

    – user3566569
    Mar 28 at 13:09
















How is this "not working"? Crash? Unexpected behavior?

– tir38
Mar 28 at 2:21





How is this "not working"? Crash? Unexpected behavior?

– tir38
Mar 28 at 2:21













As I wrote it stops on OutputStream os = urlConnection.getOutputStream();. That part is not executed and nothing happens, app doesn't crash, just that part is not executed.

– user3566569
Mar 28 at 13:09





As I wrote it stops on OutputStream os = urlConnection.getOutputStream();. That part is not executed and nothing happens, app doesn't crash, just that part is not executed.

– user3566569
Mar 28 at 13:09












2 Answers
2






active

oldest

votes


















1















Try this add Manifest.xml



cleartextTrafficPermitted="true"


it look like this
How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?






share|improve this answer



























  • Thank you, I added android:usesCleartextTraffic="true" in application tag inside AndroidManifest.xml and it works!

    – user3566569
    Mar 27 at 22:04


















0















This is because of Apache HTTP client depreciation ,
So add the below line in
tag.



<uses-library android:name="org.apache.http.legacy" android:required="false"/>





share|improve this answer

























  • I tried to add that tag and it didn't worked. Solution by Hasan Kucuk to add cleartextTrafficPermitted="true" worked.

    – user3566569
    Mar 27 at 22:20



















2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1















Try this add Manifest.xml



cleartextTrafficPermitted="true"


it look like this
How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?






share|improve this answer



























  • Thank you, I added android:usesCleartextTraffic="true" in application tag inside AndroidManifest.xml and it works!

    – user3566569
    Mar 27 at 22:04















1















Try this add Manifest.xml



cleartextTrafficPermitted="true"


it look like this
How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?






share|improve this answer



























  • Thank you, I added android:usesCleartextTraffic="true" in application tag inside AndroidManifest.xml and it works!

    – user3566569
    Mar 27 at 22:04













1














1










1









Try this add Manifest.xml



cleartextTrafficPermitted="true"


it look like this
How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?






share|improve this answer















Try this add Manifest.xml



cleartextTrafficPermitted="true"


it look like this
How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?







share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 5 at 11:52

























answered Mar 27 at 21:43









Hasan KucukHasan Kucuk

5171 gold badge4 silver badges20 bronze badges




5171 gold badge4 silver badges20 bronze badges















  • Thank you, I added android:usesCleartextTraffic="true" in application tag inside AndroidManifest.xml and it works!

    – user3566569
    Mar 27 at 22:04

















  • Thank you, I added android:usesCleartextTraffic="true" in application tag inside AndroidManifest.xml and it works!

    – user3566569
    Mar 27 at 22:04
















Thank you, I added android:usesCleartextTraffic="true" in application tag inside AndroidManifest.xml and it works!

– user3566569
Mar 27 at 22:04





Thank you, I added android:usesCleartextTraffic="true" in application tag inside AndroidManifest.xml and it works!

– user3566569
Mar 27 at 22:04













0















This is because of Apache HTTP client depreciation ,
So add the below line in
tag.



<uses-library android:name="org.apache.http.legacy" android:required="false"/>





share|improve this answer

























  • I tried to add that tag and it didn't worked. Solution by Hasan Kucuk to add cleartextTrafficPermitted="true" worked.

    – user3566569
    Mar 27 at 22:20















0















This is because of Apache HTTP client depreciation ,
So add the below line in
tag.



<uses-library android:name="org.apache.http.legacy" android:required="false"/>





share|improve this answer

























  • I tried to add that tag and it didn't worked. Solution by Hasan Kucuk to add cleartextTrafficPermitted="true" worked.

    – user3566569
    Mar 27 at 22:20













0














0










0









This is because of Apache HTTP client depreciation ,
So add the below line in
tag.



<uses-library android:name="org.apache.http.legacy" android:required="false"/>





share|improve this answer













This is because of Apache HTTP client depreciation ,
So add the below line in
tag.



<uses-library android:name="org.apache.http.legacy" android:required="false"/>






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 22:15









Saurav KumarSaurav Kumar

1367 bronze badges




1367 bronze badges















  • I tried to add that tag and it didn't worked. Solution by Hasan Kucuk to add cleartextTrafficPermitted="true" worked.

    – user3566569
    Mar 27 at 22:20

















  • I tried to add that tag and it didn't worked. Solution by Hasan Kucuk to add cleartextTrafficPermitted="true" worked.

    – user3566569
    Mar 27 at 22:20
















I tried to add that tag and it didn't worked. Solution by Hasan Kucuk to add cleartextTrafficPermitted="true" worked.

– user3566569
Mar 27 at 22:20





I tried to add that tag and it didn't worked. Solution by Hasan Kucuk to add cleartextTrafficPermitted="true" worked.

– user3566569
Mar 27 at 22:20



Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현