Chegou a fazer debug?
Será que não está entrando no IF e no ELSE?
A chamada do Asynk é feita em que momento? no onResume()?
2013/8/1 Gabriel Malinosqui <gabrielmalinosqui@gmail.com>
Chamo apenas uma vez a minha AsycTask porem vejo no logo e ela ta sendo executada 2 vezes, o que pode ser?Código da classe:
class atualizar extends AsyncTask<String, String, String>{protected void onPreExecute(){super.onPreExecute();pDialog = new ProgressDialog(Update_linhas.this);pDialog.setMessage("Baixando linhas atualizadas, aguarde...");pDialog.setIndeterminate(false);pDialog.setCancelable(false);pDialog.show();}@Overrideprotected String doInBackground(String... arg0) {// TODO Auto-generated method stubtry{HttpClient httpclient = new DefaultHttpClient();HttpPost httppost = new HttpPost("http://gargsolutions.com.br/ws.php?parametro=1");HttpResponse response = httpclient.execute(httppost);HttpEntity entity = response.getEntity();InputStream webs = entity.getContent();try{BufferedReader reader = new BufferedReader(new InputStreamReader(webs, "iso-8859-1"),8);StringBuilder sb = new StringBuilder();String line = null;while ((line = reader.readLine()) !=null){sb.append(line +"\n");}webs.close();result=sb.toString();}catch(Exception e){Log.e("tag", "Erro ao converter resultado em string" +e.toString());}}catch(Exception e){Log.e("tag", "Erro na conexão" +e.toString());}try{JSONArray jArray = new JSONArray(result);for (int i =0; i<jArray.length(); i++){JSONObject json_data = jArray.getJSONObject(i);inseriBanco1(json_data.getInt("_id"), json_data.getString("nome_onibus"));}}catch (Exception e) {// TODO: handle exceptionLog.e("tag", "Erro ao inserir dados." +e.toString());}return null;}protected void onPostExecute(String file_url) {pDialog.dismiss();}}
Como estou chamando ela na minha activity:--
if(verificaRegistro1()){try{bancoDados = openOrCreateDatabase("busao", MODE_WORLD_READABLE, null);bancoDados.delete("onibus", null, null);Log.i("verifica", "existem dados1 e estou deletando");new atualizar().execute();}catch(Exception e){Log.i("verifica", "existem dados1 mas não estou deletando porque: "+e);}}else{Log.i("verifica", "nãe existem dados1");new atualizar().execute();}
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Analista-Programador
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 comentários:
Postar um comentário