這是問題: 當我嘗試通過php頁面查詢數據庫,查詢的結果沒有「到達」智能手機。與活動和查詢問題與飛利浦的MySQL服務器
setPartenza(tBoxPartenza.getText().toString());
setArrivo(tBoxArrivo.getText().toString());
final String KEY_FERM1 = "ferm_1";
final String KEY_FERM2 = "ferm_2";
String url = "<url>";
String ferm_1, ferm_2, jsonresp;
String result = null;
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(MainActivity.this, "Response: " + response, Toast.LENGTH_SHORT).show();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity.this, "That didn't work!", Toast.LENGTH_SHORT).show();
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put(KEY_FERM1, getPartenza());
params.put(KEY_FERM2, getArrivo());
return params;
}
};
// Add the request to the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
queue.add(stringRequest);
if (result != null) {
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, false);
recyclerView = (RecyclerView) findViewById(R.id.mainRecyclerView);
recyclerView.setLayoutManager(layoutManager);
MainRecyclerAdapter adapter = null;
try {
adapter = new MainRecyclerAdapter(getApplicationContext(), result);
} catch (JSONException e) {
e.printStackTrace();
}
recyclerView.setAdapter(new AlphaInAnimationAdapter(adapter));
} else {
Toast.makeText(this, "result == null", Toast.LENGTH_SHORT).show();
}
當系統執行此,在回收不會出現什麼,bcause結果變量等於什麼都沒有,好,我不知道是否凌空獲得鎖,直到查詢到達,我也敢肯定的PHP頁面的結果,但我不知道我錯在哪裏,有什麼想法?
你的意思是我需要使用本地數據庫和用它查詢? –
你可以使用firebase(數據庫作爲服務)幾乎免費的谷歌..你可以找到他們的教程在網站上 – angryBird
它的快速簡單易用和不復雜,因爲這些網絡服務器 – angryBird