0

在 Android Studio 上,我正在开发一个应用程序连接到扫描仪的项目。扫描仪拍摄手指的照片并将其发送到应用程序。问题是,我想告诉用户他可以在拍照时移开手指。但是该消息仅在所有计算结束时打印。这是代码:

public void sendAndRequestResponse() throws JSONException {
    mRequestQueue = Volley.newRequestQueue(this);
    List<Bitmap> listI = new ArrayList<>();
    final String preurl = "http://";
    final String get_image = ":8000/api/debug/get_image_plain";
    JSONObject jsonObject = new JSONObject();
    String url = preurl + getIpScanner() + get_image;
    JsonObjectRequest objReq = new JsonObjectRequest(Request.Method.GET, url, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                JSONArray jsonArray = response.getJSONArray("c");
                JSONObject datacam1 = jsonArray.getJSONObject(0);
                JSONObject datacam2 = jsonArray.getJSONObject(1);

                print("Remove your finger"); //I would like this to be done immediately

                //Here I have all the code that process the images and take some time
                
                //And here I show the proceed images

                imageview1.setImageBitmap(byteToBitmap(extracted));
                imageview2.setImageBitmap(byteToBitmap(extracted2));

            } catch (JSONException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            print("Hourra");
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            print("argh");
            print(error.toString());
        }
    });
    mRequestQueue.add(objReq);

}

问题是,消息在最后打印,同时显示图像。我希望在将手指放在扫描仪中不再有用的那一刻打印它。

我尝试使用 Runnable,我尝试了 runOnUiThread,但似乎没有任何效果。

有谁知道我该怎么办?

4

0 回答 0