seen from United States
seen from Yemen
seen from United States

seen from China
seen from United States

seen from United States
seen from Brazil
seen from United States

seen from Brazil
seen from United States
seen from France
seen from United States
seen from China
seen from Dominican Republic
seen from United States

seen from United States

seen from United States
seen from United Kingdom
seen from United Kingdom

seen from Bulgaria
OkHttp 4正式版發布 從Java切換到Kotlin
而“沒什麼改變”是指項目保持了其它所有內容都不變,新版本是二進制和Java 源兼容的,保留了與Android 5+ 和Java 8+ 相同的最低要求,使用japicmp 強制執行二進制兼容性,並保持測試套件不變以檢測意外差異。開發團隊花了許多時間與精力保持 OkHttp 4 與 3.x 的嚴格兼容性,甚至保持了相同的包名:okhttp3。
同時,為了讓用戶更好地從 3.X 升級到 4 版本,官方還給出了一個引導手冊:
http://square.github.io/okhttp/upgrading_to_okhttp_4
OkHttp 是一個適用於 Android、Kotlin 和 Java 應用的 HTTP 和 HTTP/2 客戶端,它的使用非常簡單,支持阻塞式的同步請求和帶回調的異步請求。
更新說明:
https://github.com/square/okhttp/blob/master/CHANGELOG.md
https://cashapp.github.io/2019-06-26/okhttp-4-goes-kotlin
訪問:
阿里雲 – 最高1888元通用代金券立即可用
.
from OkHttp 4正式版發布 從Java切換到Kotlin via KKNEWS
Membuat Gallery Image Dengan Android Studio
Tutorial android hari ini adalah membuat gallery image. Data berupa file json (image dan text) diambil dari server menggunakan okhttp, dan ditampilkan menggunakan recyclerview serta picasso. File jason yang akan kita gunakan adalah http://cumabelajar.com/latihan/posterfilm.json nampak seperti ini, [{ "judul": "Star Wars VIII", "url":…
View On WordPress
Android: Upload File Images Using OKHTTP part-2
This tutorial will explain how we can upload any image or other files using okhttp. First, you must prepare the server side that will process and save the uploaded image, and I’ve written the tutorial on https://cumabelajar.com/belajar/android/upload-file-gambar-menggunakan-android-dan-php-bagian-1/
If you have read it (upload.php), please consider what variables are captured by the php script.…
View On WordPress
ProgressManager
New Post has been published on http://www.androidvisual.com/progressmanager/
ProgressManager
[vc_row row_height_percent=”0″ overlay_alpha=”50″ gutter_size=”3″ column_width_percent=”100″ shift_y=”0″ z_index=”0″][vc_column width=”1/2″][vc_column_text]
Features
[/vc_column_text][vc_separator sep_color=”color-209315″ icon=”fa fa-check” type=”dashed”][vc_column_text]
Min SDK : 14
[/vc_column_text][vc_column_text]
Price : Free
[/vc_column_text][vc_column_text]
Language : Java
[/vc_column_text][/vc_column][vc_column width=”1/2″][vc_column_text]
Download
[/vc_column_text][vc_separator sep_color=”color-dfgh” icon=”fa fa-folder-open” type=”dashed”][vc_column_text]
Link : Github
[/vc_column_text][vc_column_text]
Owner : JessYanCoding
[/vc_column_text][vc_column_text]
Source Code : Download
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_separator][/vc_column][/vc_row]
ProgressManager
Listen the progress of downloading and uploading in Okhttp (compatible Retrofit and Glide).
中文说明
Overview
Introduction
ProgressManager a line of code to listen App all the links and upload the progress of the network, including Glide picture loading progress, to achieve the principle of similar EventBus, you can be in anywhere in App, the number of listeners to Url address as an identifier, registered to the framework, when this Url address haves to download or upload the action, the framework will take the initiative to call All listeners registered with this Url address are synchronized to multiple modules.
Feature
Easy to use, just a line of code to listen progress.
Multi-platform support, support Okhttp , Retrofit , Glide ,Use Okhttp native Api , there is no compatibility problem.
Low coupling, the actual request and the progress of the receiver does not exist directly or indirectly, that can be anywhere in App to receive progress information.
Low intrusion, use this framework you do not need to change the code before uploading or downloading, ie using or not using this framework does not affect the original code.
Multi-end synchronization, the same data source upload or download progress can specify a number of different receivers, less to use EventBus achieve multiple port synchronization update progress.
Support multi-file upload
Automatic management of the listener, less to manually cancel the trouble of the listener.
The default run in the main line layer, less to switch the thread of trouble.
Lightweight framework, does not contain any three-party library, very small size.
Download
compile 'me.jessyan:progressmanager:1.3.3'
Usage
Step 1
// When building OkHttpClient, the OkHttpClient.Builder() is passed to the with() method to initialize the configuration OkHttpClient = ProgressManager.getInstance().with(new OkHttpClient.Builder()) .build();
Step 2
// Glide load ProgressManager.getInstance().addResponseListener(IMAGE_URL, getGlideListener()); // Okhttp/Retofit download ProgressManager.getInstance().addResponseListener(DOWNLOAD_URL, getDownloadListener()); // Okhttp/Retofit upload ProgressManager.getInstance().addRequestListener(UPLOAD_URL, getUploadListener());
ProGuard
-keep class me.jessyan.progressmanager.** *; -keep interface me.jessyan.progressmanager.** *;
Donate
About Me
Email: [email protected]
Home: http://jessyan.me
掘金: https://gold.xitu.io/user/57a9dbd9165abd0061714613
简书: http://www.jianshu.com/u/1d0c0bc634db
License
Copyright 2017, jessyan Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
HTTP ステータスコードの定数をどうするか?
問題
Apache の HTTP Client を OkHttp に置き換える際、HTTP ステータスコードの定数をどうするか?調べてみたら Qiita に書くほどのことでもなかったのでここに書く。
背景
Android SDK では Apache の HTTP Client がデファクトスタンダードだった(と思う、少なくとも私の会社では HTTP Client のコードの方が良く見る)のに、突然 Android 5.1 で deprecated 扱いされて、Android 6 以降は標準から消えるというすさまじいことをやってくれていた。Android で非同期通信をするためのライブラリに Volley というのがあったのだが、それが Http Client に依存していたので、6系からは(build.gradle に設定を記述しないと)使えなくなるとかいうギャグみたいな状況になっていたという。
で、Android アプリ開発者たちに代替としてもてはやされた HTTP Client が、Square 社の開発した OkHttp である。Kotlin の影響を受けたらしい現代的なインターフェイスを備えるこのライブラリはコードを書く楽しさのある素敵な一品で、Android SDK の依存がないので通常の Java アプリケーションでも使うことができる。実際私は社内の Scala のアプリケーション開発でこのライブラリをゴリ押しして採用させた。
実はなかった
前置きが長くなった。Apache の HTTP ライブラリには HttpStatus でステータスコードを示す定数が一通り定義されている。
https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/HttpStatus.html
……が、OkHttp 3系にはそれらしきクラスや定数がなかった。なぜだ。
代替案
調べてみたところ、HttpURLConnection にステータスコードを示す定数が一通り定義してあるようだ。
https://docs.oracle.com/javase/jp/8/docs/api/constant-values.html#java.net.HttpURLConnection.HTTP_ACCEPTED
まあ、これを使えばよいのかな……static import すれば HTTP_OK だけで済むわけだし……
実際、 OkHttp3 内部では
軽く見てみたところ、Response クラスで思いっきり上記の定数を使っていたという。
https://github.com/square/okhttp/blob/7135628c645892faf1a48a8cff464e0ed4ad88cb/okhttp/src/main/java/okhttp3/Response.java#L26-L31
そして、ごく一部の定数だけは内部的に定義して使っているようだ。
https://github.com/square/okhttp/blob/7135628c645892faf1a48a8cff464e0ed4ad88cb/okhttp/src/main/java/okhttp3/internal/http/StatusLine.java#L26-L28
よくわからない実装方針である……
結論
HttpURLConnection の定数を使おう。あるいは、それらのラッパーenumを作って使うとよい。
//创建okHttpClient对象 val mOkHttpClient = OkHttpClient() //创建一个Request val request = Request.Builder() .url("http://192.168.1.104:3000") .build() //new call val call = mOkHttpClient.newCall(request) //请求加入调度 call.enqueue(object : Callback { override fun onFailure(call: Call?, e: IOException?) { println("======onFailure==========") } override fun onResponse(call: Call?, response: Response?) { var htmlStr = response?.body()?.string() println("======onResponse==========") println(htmlStr) } })
How to use OkHttp3 in Android
How to use OkHttp3 in Android
HTTP call are an integral part of an Android app which access internet. OkHttp is a popular library among Android developers for HTTP calls. In OkHttp 3 a huge design change has been done by Square. Even to differentiate this version with 2.x, it has package name called “okhttp3”.
Some of the major changes in 3.0
There is no longer a global singleton connection pool. In OkHttp 2.x, all OkHttpClie…
View On WordPress