即使在使用try catch块后也没有显示任何内容

时间:2015-03-07 12:20:00

标签: java android json

这个块既没有在日志中给出错误,也没有在字符串体中添加任何值

    try {
        int roll = 00111502713;
        //url defined is completely fine//
        URL url = new URL("someurl");
        URLConnection con = url.openConnection();
        InputStream in = con.getInputStream();
        encoding = con.getContentEncoding();
        encoding = encoding == null ? "UTF-8" : encoding;
        try {
            body = IOUtils.toString(in, encoding);
            Toast.makeText(FirstActivity.this, "Body found", Toast.LENGTH_SHORT).show();
        } catch (Exception e) {
            Log.e("Log_tag", "Hahaha");

        }
    } catch (Exception ex) {
        //     System.out.println("This shouldn't have happened");
        Log.e("Log_Tag", "Really?");
    }

1 个答案:

答案 0 :(得分:0)

你必须致电:

Toast.makeText(FirstActivity.this,"Body found",Toast.LENGTH_SHORT).show();