日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android网络请求 post

發布時間:2025/6/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android网络请求 post 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>


?最近剛了解網絡請求post

  • android-async-http-1.4.8.jar

  • AsyncHttpClient?cilent;

    cilent?=?new?AsyncHttpClient();

    .setOnClickListener(View.OnClickListener()?{onClick(View?v)?{//?登錄監聽事件 b_dl.setOnClickListener(new?View.OnClickListener()?{public?void?onClick(View?v)?{{RequestParams?params?=?RequestParams();=?.getText().toString();=?.getText().toString();String?pwd?=?MD5Util.();JSONObject?jo?=?JSONObject();String?deviceName?=?android.os.Build.+?+?android.os.Build.;jo.put(,?);jo.put(,?pwd);jo.put(,?);jo.put(,?);jo.put(,?deviceName);Log.(,?Device.);jo.put(,?Device.);jo.put(,?Device.);StringEntity?entity?=?StringEntity(jo.toString());requsetData(entity);}?(Exception?e)?{e.printStackTrace();}} });

    requsetData(StringEntity?params)?{String?url?=?;.post(,?url,?params,?,?JsonHttpResponseHandler()?{onSuccess(statusCode,?Header[]?headers,?JSONObject?response)?{.onSuccess(statusCode,?headers,?response);{status?=?;(response.has())?{?status?=?response.getBoolean();}(status)?{Toast.(LoginActivity.,?,?Toast.).show();userid?=?;String?username?=?;String?token?=?;JSONObject?jo?=?response.getJSONObject();(jo.has())?{userid?=?jo.getInt();}(jo.has())?{username?=?jo.getString();}(jo.has())?{token?=?jo.getString();}.edit().putInt(,?userid).putString(,?username).putString(,?token).commit();(.isChecked())?{SharedPreferences.Editor?editor?=?.edit();editor.putString(,?);editor.putString(,?);editor.commit();}Intent?intent?=?Intent(LoginActivity.,?MainActivity.);LoginActivity..startActivity(intent);finish();}?{String?msg?=?;(response.has())?{msg?=?response.getString();}Toast.(LoginActivity.,?msg,?Toast.).show();}}?(Exception?e)?{e.printStackTrace();}}onFailure(statusCode,?Header[]?headers,?Throwable?throwable,?JSONArray?errorResponse)?{.onFailure(statusCode,?headers,?throwable,?errorResponse);Toast.(LoginActivity.,?,?Toast.).show();}}); } 接口[apiurl]為接口地址 3.1.1.登陸 用戶調用登陸接口可以獲取一個身份令牌,用于需要身份驗證的接口調用。 url: http://[apiurl]/base/logon 輸入參數說明 username?string?登錄用戶名 password?string?密碼密文,方法為md5 lon?double?經度,double,-180~180,6位小數東經為正數,西經為負數,未獲取到填0 lat?double?緯度double,-90~90,6位小數,北緯為正數,南緯為負數,未獲取到填0 devicemodel?string?手機設備信息(MI?4C,?IPHONE?5) deviceversion?String?手機系統版本(IPHONE?OS-8.13,?android?4.4.4) devicename?String?手機名稱(我的iPhone,?我的小米) *md5結果采用32位全大寫格式 輸出參數說明 token?string?用戶身份令牌,需要app記錄每次請求都需要攜帶本參數,長度48字節 userid?int?用戶編號 username?string?登錄用戶名?或者手機號


    轉載于:https://my.oschina.net/u/2601891/blog/607304

    總結

    以上是生活随笔為你收集整理的android网络请求 post的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。