个人每日总结

昨日:图片裁剪功能实现

今日:文字输入查询出现bug,未成功解决,

明天继续解决。实在不行考虑其他办法解决

问题:文字输入查询出现bug,无法成功调用

    private void getRecognitionResult(String goods) {
        //使用Get异步请求
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                //拼接访问地址
                .url("http://api.tianapi.com/txapi/lajifenlei/index?key=783da68c7ea7e10fcd259db651cc550b&word=" + goods)
                .build();
        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String result = response.body().string();
                if (response.isSuccessful()) {//回调的方法执行在子线程。
                    Log.d("result: ", result);
                }
            }
        });
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //获取识别的结果
        getRecognitionResult("眼镜");
    }

 

posted @ 2023-04-20 23:07  摆烂达人  阅读(7)  评论(0编辑  收藏  举报