android-volley 相关问题

Volley是一个适用于Android的Google库,可以更轻松,更快速地进行网络和远程图像加载。

Android Compose 带参数的 Volley Post 请求

我需要在 Android Kotlin Compose 中使用 Volley 发出请求。 该请求采用 POST 方法,有 2 个参数:电子邮件和令牌。 我提出了一个简单的请求,但我不知道如何添加参数。 可以一些...

回答 1 投票 0

如何从 Android 应用程序访问本地运行的 django REST 项目 api?

我有一个 django REST 项目,它在我的笔记本电脑上本地运行。我正在开发一个 android 应用程序来使用此 django 项目提供的 api。我的笔记本电脑和 Android 设备都连接到...

回答 2 投票 0

带有基本身份验证标头的 Volley JsonObjectRequest 不起作用

我正在尝试使用 JsonObjectRequest 发送用户名和密码作为基本授权。我尝试重写 getHeaders() 方法,但没有成功。这是我的代码: 公共类 NewPostRequest

回答 2 投票 0

在 json body volley post 请求中使用输入数据

我是 android 编程和 JSON 的新手。我正在尝试使用 volley post 请求调用身份验证 API。我正在尝试获取用户插入的用户名和密码并将其发送到 API...

回答 1 投票 0

com.android.volley.ParseError:org.json.JSONException:java.lang.String类型的新值无法转换为JSONObject

在适用于移动开发的 Android Studio 和 IntelliJ 上工作,在注册页面上工作时,发送请求后出现此错误 com.android.volley.ParseError:org.json.JSONException:新值...

回答 1 投票 0

如何创建位图适配器并将其显示在ImageView中

我是 Kotlin 和 Android Studio 的初学者,我想请求帮助来解决这个问题: 从 URL 下载图像; 创建Adapter模块来接收位图; 通过

回答 1 投票 0

如何创建一个 StringRequest,它在 php 脚本中执行 POST 来初始化参数,并在获取返回的 JSON 时执行 GET

所以我有一个在mysql数据库中搜索数据的php脚本,但是对于搜索我想输入参数。通过 POST 来自 android 应用程序的参数 所以我有一个在 mysql 数据库中搜索数据的 php 脚本,但对于搜索我想输入参数。通过 POST 来自 android 应用程序的参数 <?php $parametre=$_POST['parametre']; $ordre=$_POST['ordre']; $donneecherchee=$_POST['donneerecherchee']; $auteur=$_POST['auteur']; $recenseur=$_POST['recenseur']; //database constants define('DB_HOST', 'xxx.xxx.xxx.xxx'); define('DB_USER', 'xxxx'); define('DB_PASS', 'xxxxxxxx'); define('DB_NAME', 'xxxxxxx'); // Connect to the MySQL database //connecting to database and getting the connection object $conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); //Checking if any error occured while connecting if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); die(); } if ($parametre != null && $ordre != null && $auteur != null && $donneecherchee != null) { // echo(" Les paramatres sont:".$parametre.",".$ordre.",".$auteur.",".$donneecherchee.",".$recenseur); if ($auteur == "Mes recensements") { $queryused = "SELECT id, nom, dateprise, cin, observation, recenseur, usedurl FROM tsena WHERE " . $parametre . " = '" . $donneecherchee . "' AND recenseur = '" . $recenseur . "' ORDER BY id " . $ordre.";"; $executedquery = $conn->prepare($queryused); $executedquery->execute(); $executedquery->bind_result($id, $nom, $dateprise, $cin, $observation, $recenseur, $usedurl); $tsena = array(); // traversing through all the result while ($executedquery->fetch()) { $temp = array(); $temp['id'] = $id; $temp['nom'] = $nom; $temp['dateprise'] = $dateprise; $temp['cin'] = $cin; $temp['observation'] = $observation; $temp['recenseur'] = $recenseur; $temp['usedurl'] = $usedurl; array_push($tsena, $temp); } // echo the result as JSON echo json_encode($tsena); } else { $queryused2 = "SELECT * FROM tsena WHERE " . $parametre . " = '" . $donneecherchee . "' ORDER BY id " . $ordre .";"; $executedquery2 = $conn->prepare($queryused2); $executedquery2->execute(); $executedquery2->bind_result($id, $nom, $dateprise, $cin, $observation, $recenseur, $usedurl); $tsena2 = array(); // traversing through all the result while ($executedquery2->fetch()) { $temp = array(); $temp['id'] = $id; $temp['nom'] = $nom; $temp['dateprise'] = $dateprise; $temp['cin'] = $cin; $temp['observation'] = $observation; $temp['recenseur'] = $recenseur; $temp['usedurl'] = $usedurl; array_push($tsena2, $temp); } // echo the result as JSON echo json_encode($tsena2); } }else{ $data = [ "id" => 0, "nom" => "Aucun", "dateprise" => "Aucune date", "cin" => "Aucun CIN", "observation" => "Aucune observation", "recenseur" => "Aucun recenseur", "usedurl" => "Aucune image" ]; // Output the JSON data echo json_encode([$data]); } ?> 我想获取返回的 json 并将其显示在我的应用程序中,但这需要我使用 GET 创建另一个 StringRequest,这样做将创建一个带有空参数的脚本。 Android 部分如下: `private void loadProducts(String parametre, String ordre, String donneerecherchee,String auteur,String recenseur) { StringRequest stringRequest = new StringRequest(Request.Method.POST, URL_tsena, 新的 Response.Listener() { @覆盖 公共无效onResponse(字符串响应){ 尝试 { JSONArray 数组 = 新 JSONArray(响应); System.out.println("服务器响应:"+response); //traversing through all the object for (int i = 0; i < array.length(); i++) { JSONObject product = array.getJSONObject(i); //adding the product to product list tsenaList.add(new Tsena( product.getInt("id"), product.getString("nom"), product.getString("cin"), product.getString("dateprise"), product.getString("observation"), product.getString("recenseur") )); } //creating adapter object and setting it to recyclerview TsenaAdapter adapter = new TsenaAdapter(ConsultTsena.this, tsenaList); recyclerView.setAdapter(adapter); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(ConsultTsena.this,"Erreur de load:"+error,Toast.LENGTH_LONG).show(); Log.e("Volley Erreur", error.toString()); } }){ @Override protected Map<String, String> getParams() { Map<String, String> params = new HashMap<>(); params.put("parametre", parametre); params.put("ordre", ordre); params.put("donneerecherchee",donneerecherchee); params.put("auteur",auteur); return params; // Set the parameters for the request } }; //adding our stringrequest to queue Volley.newRequestQueue(this).add(stringRequest); }` 我能做什么? 我测试过: 查看参数是否传入 如果查询不正确; 我的 logcat 中有一个空的 json [],这不应该是这样,因为我在 Powershell 中执行查询并返回了一些东西。 抱歉打扰大家,我只是把参数设置为GET。我通过 android 部分的 url 拍摄它们。它确实有效,但不是很安全

回答 1 投票 0

直播意外结束

我不断收到 MalformedStreamException 我正在使用 Java 8 运行 tomcat 9 客户端正在发送分段文件上传(图片和图片名称) 这是函数签名: 导入 org.springframew...

回答 3 投票 0

将变量从 Android 应用程序发送到 MySQL 数据库时出现问题

我想使用 POST 将字符串值从我的应用程序传递到 MySQL localhost 数据库,但是当我调用函数 registerUser() 时,我的数据库没有收到它。这是负责发送的代码...

回答 1 投票 0

反应原生找不到com.android.volley:volley:1.1.1

我使用react native 66运行yarn android时出现错误 纱线运行 v1.22.17 $ 反应本机运行 Android 信息 运行 jetifier 将库迁移到 AndroidX。您可以使用“--no-

回答 3 投票 0

如何/在哪里存储 Android 中的 HTTP 请求 URL?

我不确定应该如何/在哪里存储我的 Http-Request URL 以及如何组织它们。 我正在为 Android 开发服务器和客户端。在客户端上,我使用 Volley 进行网络通信

回答 3 投票 0

如何获取 volley cookies 并在下一个请求时设置它 - android

我使用Django,当用户通过API登录时,发送到Android的响应包含一个包含CSRF和会话的cookie,我需要接收它的值并将它们发送到头部...

回答 1 投票 0

如何在物理智能手机上作为本地服务器运行

我正在同时开发Android Studio前端和Springboot后端。 让 Springboot 作为本地主机运行, 我正在通过连接到

回答 1 投票 0

如何在android中使用Volley库上传文件?

我已经有一个 Request 的子类,用于将 http post 发送到服务器。问题是,我不知道如何为文件添加参数。将字符串发布到服务...

回答 1 投票 0

handleWindowVisibility:令牌 android.os.BinderProxy 没有活动

我有一个登录屏幕,成功登录后,它会完成并显示另一个包含用户信息的页面。 我读过这篇文章以及这篇文章。 我还阅读了很多关于我们如何扩展的内容

回答 6 投票 0

如何在没有上下文的情况下使用 volley 或可组合上下文的替代方案?

val 队列需要一个上下文,而我必须使用上下文,所以我必须使用 @Composable,这样我才能编写 val 上下文。但问题是我想用这个功能的地方却没有

回答 1 投票 0

如何修复android studio中的com.android.volley.ClientError

当我单击登录按钮时,会出现该警报,我使用 com.android.volley:volley:1.1.1 对于 api,我使用 python 中的 Restframework 这是我的 mainactivity.java 代码 @覆盖 受保护无效...

回答 2 投票 0

使用 Volley 库获取 com.android.volley.ServerError。可能的原因有哪些?

当我在 Volley 中发出请求时,我收到 com.android.volley.ServerError 和响应代码 400。 我正在做这样的事情(通用示例代码): 最终字符串参数1 =“...”; 最后

回答 8 投票 0

如何在 Kotlin 中使用 volley 将标头放入 url 中?

我的代码- val accessTokenRequest: JsonObjectRequest = JsonObjectRequest(Request.Method.GET, url, Response.Listener { 响应 -> }, Response.ErrorListener { e...

回答 2 投票 0

获取 com.android.volley.ServerError

使用 volley 发出 PUT 请求 Log.i("JsonObject 是",finaljsonData.toString()); 输出:- {“stats”:[{“med_id”:1,“med_name”:“晚上”,“start_date”:1476107306168,“end_date”:1476193706168,“坚持”:{“tak...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.