【问题标题】:theMovieDB api call throwing IOEXceptionTheMovieDB api 调用抛出 IOEXception
【发布时间】:2017-01-22 08:17:33
【问题描述】:

我正在制作一个使用MovieDB API 的android 应用程序。 看看我的类扩展 AsyncTask 的部分。

private HttpURLConnection urlconnection = null;
    private URL url;

    protected String doInBackground(String[] task)
    {
        String DATA=null;
        String baseAddress="https://api.themoviedb.org/3/movie/";
        String apiKey="225b36fd29826b4c9821dd90bfc4e055";
        Uri Url = Uri.parse(baseAddress).buildUpon().appendEncodedPath(task[0]).appendQueryParameter("api_key",apiKey).build();
        Log.d("built URL",Url.toString());
        try
        {
            url= new URL(Url.toString());
            urlconnection= (HttpURLConnection) url.openConnection();
            urlconnection.setRequestMethod("GET");
            urlconnection.connect();

            InputStream inputStream = urlconnection.getInputStream();
            if (inputStream==null)
            {
                return null;
            }
            BufferedReader reader= new BufferedReader(new InputStreamReader(inputStream));
            StringBuffer buffer=null;
            String line;

            while ((line=reader.readLine())!=null)
            {
                buffer.append(line+'\n');
            }
            DATA=buffer.toString();

        }

我收到 IOException(在 logcat 中看到)。我在浏览器上检查了构建的 URL(它正在工作)。同一组语法确实适用于 openweather api。 themovieDb API 还需要其他什么东西吗?帮我解决。我确实检查了那里的文档,但没有关于 android 的信息。

【问题讨论】:

  • 发布你得到的异常。
  • @Januson 就是这个“E/cloudConnect:错误”
  • 你能粘贴什么 Log.d("built URL",Url.toString());正在打印吗?

标签: java android http themoviedb-api


【解决方案1】:

我得到了解决方案。我已连接到我的移动热点,但由于某种原因无法按预期工作。切换到我家的 WIFI 解决了这个问题。 感谢您抽出宝贵时间回答我的问题

【讨论】:

    猜你喜欢
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-31
    • 2014-06-28
    • 2015-07-26
    相关资源
    最近更新 更多