search

Home  >  Q&A  >  body text

android - okhttp问题

链接里有“[”或者“]”应用就会闪退,求解决方法....
源码:

OkHttpClient o=new OkHttpClient();
 Request r=new                Request.Builder().url("XXXXXXXX").build();
  o.newCall(r).enqueue(new Callback()
        {
            @Override
            public void onFailure(Request p1, IOException p2)
            {
                runOnUiThread(new Runnable()
                    {
                        @Override
                        public void run()
                        {

                        }
                    });
            }

            @Override
            public void onResponse(final Response p1)  throws IOException
            {
                final String res=p1.body().string();
                runOnUiThread(new Runnable()
                    {

                        @Override
                        public void run()
                        {
                            t.setText(res);
                        }
                    });

            }
        });
PHPzPHPz2890 days ago373

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 18:02:00

    Encode the URL first

    reply
    0
  • Cancelreply