theMovieDB api 调用抛出 IOEXception
theMovieDB api call throwing IOEXception
我正在制作一个使用 theMovieDB API 的 android 应用程序。
看看我的class扩展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.
的信息
我得到了解决方案。我已连接到我的移动热点,但由于某种原因无法按预期工作。切换到我家的 WIFI 解决了这个问题。
感谢您花时间回答我的问题
我正在制作一个使用 theMovieDB API 的 android 应用程序。 看看我的class扩展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.
的信息我得到了解决方案。我已连接到我的移动热点,但由于某种原因无法按预期工作。切换到我家的 WIFI 解决了这个问题。 感谢您花时间回答我的问题