Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Download extends AsyncTask<Void, Void, String> {
- protected String doInBackground(Void... params) {
- URL url = null;
- try {
- url = new URL( "http://dagobah.grifin.pt/tiagocoelho/Conexaotumg.php");
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- HttpURLConnection conn = null;
- try {
- conn = (HttpURLConnection) url.openConnection();
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- if( conn.getResponseCode() == HttpURLConnection.HTTP_OK ){
- InputStream is = conn.getInputStream();
- }else{
- InputStream err = conn.getErrorStream();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- String out = null;
- try {
- DefaultHttpClient httpClient = new DefaultHttpClient();
- String url_all_empresas = "http://dagobah.grifin.pt/tiagocoelho/Conexaotumg.php";
- final HttpParams httpParameters = httpClient.getParams();
- HttpConnectionParams.setConnectionTimeout(httpParameters, 15000);
- HttpConnectionParams.setSoTimeout(httpParameters, 15000);
- HttpGet httpPost = new HttpGet(url_all_empresas);
- HttpResponse httpResponse = httpClient.execute(httpPost);
- HttpEntity httpEntity = httpResponse.getEntity();
- out = EntityUtils.toString(httpEntity, HTTP.UTF_8);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- } catch (ClientProtocolException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return out;
- }
- class btnsearchclicker implements Button.OnClickListener
- {
- @Override
- public void onClick(View v){
- AlertDialog.Builder b = new AlertDialog.Builder(MainActivity.this);
- b.setTitle(overflow2);
- b.setItems((overflow.toArray(new String[linhas.size()])), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- int j = 0;
- for (j = 0; j <= overflow.size(); j++) {
- if (j == which) {
- btnstackoverflow.setText(overflow.get(j));
- }
- }
- }
- });
- b.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement