У меня есть ошибка com.android.volley.authfailureerror в майском коде. Как я могу это исправить?
моя ссылка JSON:
http://shdesign.gigfa.com/json/json_kaghaz_divari.php
но у меня есть ошибка
class Gallery : AppCompatActivity() {
val url = "http://shdesign.gigfa.com/json/json_kaghaz_divari.php"
var images: ArrayList<Album> = ArrayList()
private var locationItemAdapter: GalleryAdapter? = null
private var recyclerView: RecyclerView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_gallery)
val activity_gallery = layoutInflater.inflate(R.layout.activity_gallery, null)
setContentView(activity_gallery)
//val mAdapter=GalleryAdapter(this,images)
recyclerView=activity_gallery.actv_gallery_recyclerView as RecyclerView
var mLayoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
recyclerView!!.layoutManager = mLayoutManager
//recyclerView.layoutManager=LinearLayoutManager(this)
//recyclerView.adapter=mAdapter
fetchImage()
}
fun fetchImage(){
val pd=ProgressDialog(this)
pd.setMessage("wait...")
pd.setCancelable(false)
pd.show()
/* val req=JsonArrayRequest(url,Response.Listener<JSONArray>{
Override fun onResponse(JSONArray_response){
}
}) */
val oRequest = object : StringRequest(Request.Method.GET, url, Response.Listener {
response ->
pd.hide()
try {
val locationArray = JSONArray(response)
images=ArrayList(locationArray.length())
for (i in 0 until locationArray.length()){
val loc = locationArray.get(i) as JSONObject
images.add(Album(
loc.getString("kid"),
loc.getString("kname"),
loc.getString("kcity")
))
}
locationItemAdapter = GalleryAdapter(this,images)
recyclerView!!.setAdapter(locationItemAdapter)
}catch (e:JSONException) {
e.printStackTrace()
}
},Response.ErrorListener { error ->
Toast.makeText(applicationContext, "Error: " + (error.toString()), Toast.LENGTH_LONG).show();
pd.hide()
}) {
}
val requestQ = Volley.newRequestQueue(this)
requestQ.add(oRequest)
}
}