public int coderesult (String urlstring) throws Exception {
URL url = new URL(urlstring);
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
//System.out.println("Response code is " + httpCon.getResponseCode());
int mycode = httpCon.getResponseCode();
return mycode;
}
public int displaycode() {
int dispcode = 0;
try {
dispcode = coderesult(myurl);
}
catch (MalformedURLException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally {
}
return dispcode;
}
"dispcode = coderesult(myurl);"にAndroid Studioのエラーが表示される:「未処理の例外:java.lang.Exceptionを」HttpURLConnectionを呼び出すと未処理の例外が発生する
ポストフルスタックトレースを書き、特定の可能性があります。この 'httpCon.getResponseCode()'で何を得ましたか? –