StringRequest迴應,我已經把這個依賴 使用凌空並獲得JSON數據從一個尊重網址: - 把後沒有得到在VOLLEY
**compile 'me.neavo:volley:2014.12.09'**
這 沒有得到StringRequest響應: -
如果我使用其他URLS其工作正常,但與此URL不給我響應。
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
public class VolleyTest extends Activity {
//MY URL where i had made Json data
public static final String MainUrl = "http://mycricket.net23.net/abcd.php";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Log.d("method", "GETDATA");
RequestQueue requestQueue = Volley.newRequestQueue(this);
StringRequest request = new StringRequest(Request.Method.GET, MainUrl, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// SHow LOG of JSON data
Log.d("ResponseVolley",response);
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
//.. Adding Request
requestQueue.add(request);
}
}
嘗試將響應轉換爲JsonObject和print.may是否可以工作 –
如果您完全不知道您還沒有告訴我們您會得到什麼錯誤?如果它與其他鏈接一起工作,那麼我們應該看看你的PHP文件...另外,爲什麼你不使用谷歌存儲庫中的Volley? git clone https://android.googlesource.com/platform/frameworks/volley獲取此版本,請轉至Android Studio>新建>導入模塊,併爲下載的文件夾提供路徑。然後在應用程序build.gradle添加編譯項目(':volley')的依賴 – iBobb
我沒有得到迴應,..多數民衆贊成它 –