kodlamada nerde hata yapıyorum
Arkadaşlar kendi yazmış olduğum bu kodla sitemden veri çekiyorum AsyncTask içine yazdığımda program yazılım android tarafından kapanmaya zorlanıyor AsyncTask dışında onCreate içine yazdığımda çalışıyor bu sefer tabletde hata veriyor nasıl çözerim.
[code]
package com.sgs.lotocilginligi;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;
public class LotoSonuclari extends Activity {
public ProgressDialog dialog = new ProgressDialog(LotoSonuclari.this);
public int[] imageId = {R.drawable.image1,
R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4,
R.drawable.image5, R.drawable.image6, R.drawable.image7, R.drawable.image8,
R.drawable.image9, R.drawable.image10, R.drawable.image11, R.drawable.image12,
R.drawable.image13, R.drawable.image14, R.drawable.image15, R.drawable.image16,
R.drawable.image17, R.drawable.image18, R.drawable.image19, R.drawable.image20,
R.drawable.image21, R.drawable.image22, R.drawable.image23, R.drawable.image24,
R.drawable.image25, R.drawable.image26, R.drawable.image27, R.drawable.image28,
R.drawable.image29, R.drawable.image30, R.drawable.image31, R.drawable.image32,
R.drawable.image33, R.drawable.image34, R.drawable.image35, R.drawable.image36,
R.drawable.image37, R.drawable.image38, R.drawable.image39, R.drawable.image40,
R.drawable.image41, R.drawable.image42, R.drawable.image43, R.drawable.image44,
R.drawable.image45, R.drawable.image46, R.drawable.image47, R.drawable.image48,
R.drawable.image49, R.drawable.image50, R.drawable.image51, R.drawable.image52,
R.drawable.image53, R.drawable.image54
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sonuclistele);
new sonuclarial().execute("");
}
public class sonuclarial extends AsyncTask<String, String, String>{
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog.setMessage("Yükleniyor...");
dialog.show();
}
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(" burada kod çektiğim link var ");
HttpResponse response;
try {
response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
try {
InputStream instream = entity.getContent();
String line = "";
BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
StringBuilder json = new StringBuilder();
while ((line = reader.readLine()) != null) {
json.append(line + "\n");
}
JSONObject obj = new JSONObject(json.toString());
JSONArray Jsonuclar = obj.getJSONArray("sonuclar");
JSONObject s1 = Jsonuclar.getJSONObject(0);
JSONObject s2 = Jsonuclar.getJSONObject(1);
JSONObject s3 = Jsonuclar.getJSONObject(2);
JSONObject s4 = Jsonuclar.getJSONObject(3);
ListView lv;
lv = (ListView) findViewById(com.sgs.lotocilginligi.R.id.liste);
SatırBilgi sonucDizi[] = new SatırBilgi[]{
new SatırBilgi(1, imageId[s1.getInt("s1")], imageId[s1.getInt("s2")], imageId[s1.getInt("s3")], imageId[s1.getInt("s4")], imageId[s1.getInt("s5")], imageId[s1.getInt("s6")], "Tarih : " + s1.getString("tarih"), "Hafta : " + s1.getString("hafta"), "Model : " + s1.getString("model")),
new SatırBilgi(2, imageId[s2.getInt("s1")], imageId[s2.getInt("s2")], imageId[s2.getInt("s3")], imageId[s2.getInt("s4")], imageId[s2.getInt("s5")], imageId[s2.getInt("s6")], "Tarih : " + s2.getString("tarih"), "Hafta : " + s2.getString("hafta"), "Model : " + s2.getString("model")),
new SatırBilgi(3, imageId[s3.getInt("s1")], imageId[s3.getInt("s2")], imageId[s3.getInt("s3")], imageId[s3.getInt("s4")], imageId[s3.getInt("s5")], imageId[s3.getInt("s6")], "Tarih : " + s3.getString("tarih"), "Hafta : " + s3.getString("hafta"), "Model : " + s3.getString("model")),
new SatırBilgi(4, imageId[s4.getInt("s1")], imageId[s4.getInt("s2")], imageId[s4.getInt("s3")], imageId[s4.getInt("s4")], imageId[s4.getInt("s5")], imageId[s4.getInt("s6")], "Tarih : " + s4.getString("tarih"), "Hafta : " + s4.getString("hafta"), "Model : " + s4.getString("model"))
};
SatırAdaptor adap = new SatırAdaptor(LotoSonuclari.this, com.sgs.lotocilginligi.R.layout.list_satir, sonucDizi);
lv.setAdapter(adap);
instream.close();
} catch (Exception e) {
Toast.makeText(getApplicationContext()," Hata : "+ e, Toast.LENGTH_LONG).show();
}
}
} catch (Exception e) {
Toast.makeText(getApplicationContext()," Hata : "+ e, Toast.LENGTH_LONG).show();
}
return null;
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
dialog.dismiss();
}
}
}
[/code]