【问题标题】:Emulator can not download data from Internet (endless loading)模拟器无法从 Internet 下载数据(无限加载)
【发布时间】:2015-03-16 15:18:46
【问题描述】:

我在测试我的应用时遇到问题:它从互联网加载数据并将其输出到屏幕上。当我尝试用模拟器测试它时 - 下载开始,但没有完成。当我用普通智能手机尝试时 - 一切正常,数据在一秒钟内加载。这是一个代码,但我认为问题不在于它:

final Button butTest = (Button)findViewById(R.id.parse);
        final TextView tvInfo = (TextView)findViewById(R.id.getdata);

        butTest.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                (new AsyncLoad()).execute("http://yandex.ru");
                    }



                class AsyncLoad extends AsyncTask<String, Void, String> {

                    Document doc = null;
                    private ProgressDialog mProgressDialog;

                    @Override
                    protected String doInBackground(String... params) {
                            publishProgress(new Void[] {});
                                    try {
                                            doc = Jsoup.connect(params[0]).get();
                                    } catch (IOException e) {
                                            e.printStackTrace();
                                    }
                            return doc.title();
                    }

                    @Override
                    protected void onPreExecute() {
                            super.onPreExecute();
                            mProgressDialog = new ProgressDialog(GetData.this);
                            mProgressDialog
                                            .setMessage("Download...");
                            mProgressDialog.show();
                    }

                    @Override
                    protected void onPostExecute(String result) {
                            super.onPostExecute(result);
                            tvInfo.setText(result);
                            mProgressDialog.dismiss();
                    }
            }
        });

我在 Eclipse 中工作,这些是模拟器设置:RAM 1024、内部存储 200、VM 堆 64。它在其他测试中运行不那么快,但仍然可以运行。使用此代码,我可以等待 10、15、20 分钟 - 它会继续执行 PreExecute(),但不会更久。

【问题讨论】:

  • 你试过关闭你的模拟器,然后重新启动它
  • 如果你认为你的问题是模拟器,你能告诉我们它的细节吗?
  • 感谢您的回答,我编辑了第一篇文章。

标签: java android emulation


【解决方案1】:

检查天气,您已在模拟器设置中分配了一些内存。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    相关资源
    最近更新 更多