-3
A
回答
0
使用StringRequest單請求到服務器:
public void onClick(View view){
StringRequest stringRequest = new StringRequest(Request.Method.POST, server_url
, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//Do your stuff on response
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
//Do your stuff on Error response
});
VolleyHelper.getInstance(getApplicationContext()).getRequestQueue().add(stringRequest);
}
這裏是你的VolleyHelper類:
public class VolleyHelper {
public static VolleyHelper mSingleton;
private RequestQueue mQueue;
private static Context mContext;
private VolleyHelper(Context ctx) {
mContext = ctx;
mQueue = getRequestQueue();
}
public RequestQueue getRequestQueue() {
if (mQueue == null) {
mQueue = Volley.newRequestQueue(mContext);
}
return mQueue;
}
public synchronized static VolleyHelper getInstance(Context ctx) {
if (mSingleton == null) {
mSingleton = new VolleyHelper(ctx);
}
return mSingleton;
}
}
希望這有助於。 :)
相關問題
- 1. C#請求隊列
- 2. 請求隊列實現
- 3. RxJava的請求隊列
- 4. jQuery隊列$ .post請求
- 5. Android的請求隊列
- 6. 排隊請求隊列超時
- 7. 清理隊列中所有其他請求的GCD隊列
- 8. 請求servlet在隊列中等待
- 9. Node.js中的請求優先級隊列
- 10. Springboot API將請求放在隊列中?
- 11. WCF中的用戶請求隊列
- 12. 在C中管理請求隊列
- 13. 請求排隊多部分請求列表
- 14. 排隊請求不參數
- 15. 異步HTTP請求,排隊請求
- 16. 沖洗的Flex的VideoDisplay請求隊列
- 17. 提高asp.net的請求隊列限制
- 18. 每個客戶端的隊列請求
- 19. REST服務前的請求隊列
- 20. Azure請求隊列限制超出
- 21. Github:叉隊列對拉請求
- 22. BizTalk:隊列請求到發送端口
- 23. 使AJAX隊列稍後解析請求
- 24. 備份節點請求隊列
- 25. 凌空請求隊列返回null
- 26. WCF - 想知道請求隊列
- 27. AFNetworking和設置請求隊列
- 28. 隊列請求MVC控制器
- 29. CFQ IO調度程序請求隊列
- 30. 隊列XAP文件下載請求
因爲顯然RequestQueue構造函數不採取這樣的參數... – Selvin
那麼我選擇什麼參數來實現來自我的服務器的簡單請求。 –
你到目前爲止做了什麼?請提供代碼。 – tahsinRupam