小编vor*_*tex的帖子

Android抛出异常,e.getMessage()为null

我目前正在编写一个使用Push通知的Android应用程序.我的应用程序已成功注册Google服务器并获取ID,并且我有使用此ID的服务器端代码并​​将通知推送到收到的应用程序.

当收到推送时,我正在调用一个自定义类,它在一个线程内查询远程服务器以获取将在App中处理的信息.

调用的方法是这样的:

private Thread checkUpdate = new Thread() {
    public void run() {
        try {
            URL updateURL = new URL("http://this.site.com/some/path");
            URLConnection conn = updateURL.openConnection();

            InputStream is = conn.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);
            ByteArrayBuffer baf = new ByteArrayBuffer(50);

            int current = 0;
            while ((current = bis.read()) != -1) {
                baf.append((byte) current);
            }

            /* Convert the Bytes read to a String. */
            html = new String(baf.toByteArray());
            mHandler.post(showUpdate);

        } catch (Exception e) {
            // Show message if there was an error …
Run Code Online (Sandbox Code Playgroud)

android exception

5
推荐指数
0
解决办法
8196
查看次数

标签 统计

android ×1

exception ×1