我想創建一個PHP代碼,PHP文件包含文本Web服務,我想表明這個文本的Android textVeiwAndroid的Web服務與PHP
我通過的openConnection(用URL連接),但我在課堂上的InputStreamReader
錯誤public class MainActivity extends AppCompatActivity {
TextView text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (TextView) findViewById(R.id.textView4);
}
public void onClick(View view) throws Exception {
URL hellofileurl = null;
try {
hellofileurl = new URL("http://waaddev.ahosti.net/web.php");
HttpURLConnection myfirstconnection = (HttpURLConnection) hellofileurl.openConnection();
InputStream stream = new InputStream(myfirstconnection.getInputStream());//i have error in this line
BufferedReader b = new BufferedReader(stream);
String hello = b.readLine();
} catch (Exception e) {
e.printStackTrace();
}
}
}
哪一種例外的你好嗎?請指定更多信息... – Fortega