Good, I'm creating my first android application that is a job for the university, I've been trying for several days to solve a connection problem with a url, could you help me?
This is my code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_palabra_dificil_to_sinonimo);
txtSinonimo = (TextView) findViewById(R.id.TxtSinonimo);
//Recuperamos la información pasada en el intent
Bundle bundle = this.getIntent().getExtras();
try {
URL url = new URL(myURL + URLEncoder.encode(bundle.getString("Palabra"), "UTF-8"));InputStream is;
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.connect();
is = conn.getInputStream();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Where in myURL I have my url and the exception always jumps me in conn.connect();
Could you give me some solution?