【问题标题】:Volley doesn't pass the params?Volley 没有通过参数?
【发布时间】:2020-07-06 00:10:11
【问题描述】:

我想每次增加 +1 并将其添加到服务器 SQL 数据库。但问题是下面的代码只运行一次,其余的 +1 没有添加到服务器。我检查了很多答案,但没有一个对我有用,所以我问一下。那么有人能告诉我我在代码上犯了什么错误吗?实际上我是 volley 的新手,所以你的详细指南可以帮助我更好地学习。

我的代码 Android Studio

 queue = Volley.newRequestQueue(this);

         request = new StringRequest(StringRequest.Method.GET, "http://alfaazshayaristatus.com/apps/alfaaz/upload.php?id=" + id, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {


                Toast.makeText(ImageViewActivity.this, response, Toast.LENGTH_SHORT).show();


            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {


                Toast.makeText(ImageViewActivity.this, ""+error.getMessage(), Toast.LENGTH_LONG).show();

            }
        }

        );

        queue.add(request);

我的PHP

<?php

include 'config.php';

$id = $_GET['id'];
$response = array();


     $insert = $db->query("UPDATE AlfaazStatus SET views=views+1 WHERE id=$id");
            if($insert){


                $message = "The file id ".$id." add +1 Like";


$success = true;

            }else{


$success = false;

                $message = "File upload failed, please try again.";
            }




$response["success"] = $success;
$response["message"] = $message;

header('Content-Type:Application/json');

echo json_encode($response);
?>

【问题讨论】:

    标签: android-studio server retrofit android-volley android-networking


    【解决方案1】:

    您是否尝试使用此方法为图像添加调整大小?

    Picasso.with(getActivity())
                            .load(imageUrl)
                            .placeholder(R.drawable.placeholder)
                            .error(R.drawable.error)
                            .resize(screenWidth, imageHeight)
                            .fit.centerCrop()
                            .into(imageView);
    

    希望对你有帮助

    【讨论】:

    • 问题变了,亲爱的,但是,是的,我已将这种方法用于旧问题,并且对我有用。谢谢,但你能看看这个更新的问题
    猜你喜欢
    • 2015-12-23
    • 2013-07-26
    • 1970-01-01
    • 2020-07-24
    • 1970-01-01
    • 2020-11-20
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    相关资源
    最近更新 更多