Soru & Cevap

Android 4.4 sürümünün altında https den veri almada hata

17.09.2015 - 03:43

Selam arkadaşlar https ile hazırladığım veri sayfasından veri alırken android  4.4. ve üstü sürümlerde hata yaşamazken diğer sürümlerde hata alıyorum kodlarım şunlar yardımcı olursanız sevinirim

 

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.yemek);
		Log.i("Baglant,dan oncesi", "1");
		if (baglantilar.isOnline(getApplicationContext())) {
			Log.i("Baglanti var", "1");
			basicInitializations();
			Log.i("burdayım", "30");
		} else {
			Toast.makeText(getApplicationContext(),
					"İnternet Bağlantınızı kontrol ediniz.", Toast.LENGTH_SHORT)
					.show();
			// startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
			showDialog(DIALOG_ERROR_CONNECTION);
			// finish();
		}

	}
	
	
	
	public void basicInitializations() {
		Log.i("burdayım", "4");
		//linProgressBar = (LinearLayout) findViewById(R.id.proggressBar1);
		Log.i("burdayım", "5");
		try {
			new Thread() {
				public void run() {
					initializeApp();
					uiHandler.post(new Runnable() {
						@Override
						public void run() {
							if (isUpdateRequired) {
							} else {
								new LongOperation().execute();

							}
						}
					});
				}

				public void initializeApp() {
					// Initialize application data here
				}
			}.start();
		} catch (Exception e) {
		}
	}
	
	class LongOperation extends AsyncTask<String, Void, String> { // Asenkron
		
		ProgressDialog dialog;
		
				// çalışma
		@Override
		protected String doInBackground(String... params) {
			Log.i("burdayım", "2");
			String yemekURL = "https://xxxxxx/Takvim/jsonver";
			
			yemekresponseBody = baglantilar.postFromInternet(yemekURL,cookieTut);
			Log.i("yemekResponse", yemekresponseBody);
			return null;
			}
		@Override
		protected void onPostExecute(String result) {
			Log.i("burdayım", "3");
			Intent i = new Intent(getApplicationContext(),yemekGirdi.class);
			startActivity(i);
			finish();
		}
		@Override
		protected void onPreExecute() {
			super.onPreExecute();
			dialog = new ProgressDialog(yemek.this);
			dialog.setMessage("Biraz Zaman Alabilir Lütfen Bekleyin");
			dialog.setTitle("Menü Oluşturuluyor...");
			dialog.show();
			dialog.setCancelable(false);
		}
		
		@Override
		protected void onProgressUpdate(Void... values) {
		
		}
	}
	
	protected Dialog onCreateDialog(int id) { // programdaki tüm alertdialoglar
		Dialog dialog = null;
		switch (id) {
		case DIALOG_ERROR_CONNECTION: // internet bağlantısı sorununda
										// alertdialog
			AlertDialog.Builder errorDialog = new AlertDialog.Builder(this);
			errorDialog.setTitle("Hata");
			errorDialog.setMessage("İnternet Bağlantınızı Kontrol Ediniz.");
			errorDialog.setNeutralButton("Ayarlar",
					new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int id) {
							// dialog.dismiss();
							startActivity(new Intent(
									android.provider.Settings.ACTION_WIRELESS_SETTINGS));
						}
					});
			errorDialog.setNegativeButton("Tamam",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
							dialog.dismiss();
							finish();
						}
					});
			AlertDialog errorAlert = errorDialog.create();
			return errorAlert;
		case Zorunlu_Kapat: // veri alırken oluşn hatada kapat
			AlertDialog.Builder kapat = new AlertDialog.Builder(this);
			kapat.setMessage("Üzgünüz!!! Veriler Alınırken Hata Oluştu!!!")
					.setCancelable(false)
					.setPositiveButton("Programı Kapat",
							new DialogInterface.OnClickListener() {
								@SuppressLint("NewApi")
								public void onClick(DialogInterface dialog,
										int id) {
									yemek.this.finish();
									// moveTaskToBack(true);
								}
							})
					.setNegativeButton("Yeniden Dene",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									startActivity(new Intent(
											getApplicationContext(),
											yemek.class));
									dialog.cancel();
								}
							});
			AlertDialog kapatalert = kapat.create();
			return kapatalert;
		case YANLIS_VERI_GIRISI: // yanlış login bilgileri durumunda alertdialog
			AlertDialog.Builder errorDialog1 = new AlertDialog.Builder(this);
			errorDialog1.setTitle("Hata");
			errorDialog1.setMessage("Bilgileriniz Hatalı yada Eksik...");
			errorDialog1.setNegativeButton("Tamam",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
							dialog.dismiss();
						}
					});
			AlertDialog errorAlert1 = errorDialog1.create();
			return errorAlert1;
		case CIKIS_YAP: // GEri tuşu ve menüdeki çıkış için alertdialog
			AlertDialog.Builder cikis = new AlertDialog.Builder(this);
			cikis.setMessage("Çıkmak istediğinizden emin misiniz?")
					.setCancelable(false)
					.setPositiveButton("Evet",
							new DialogInterface.OnClickListener() {
								@SuppressLint("NewApi")
								public void onClick(DialogInterface dialog,
										int id) {
									yemekresponseBody = "";
									yemek.this.finish();
									// moveTaskToBack(true);
								}
							})
					.setNegativeButton("Hayır",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									dialog.cancel();
								}
							});
			AlertDialog cikisalert = cikis.create();
			return cikisalert;

		case EskiVersiyon: // GEri tuşu ve menüdeki çıkış için alertdialog
			AlertDialog.Builder eskiversiyon = new AlertDialog.Builder(this);
			eskiversiyon
					.setMessage(
							"Programın yeni sürümü mevcut. Güncellemeyi yapmanız gerekmektedir.")
					.setCancelable(false)
					.setPositiveButton("Evet",
							new DialogInterface.OnClickListener() {
								@SuppressLint("NewApi")
								public void onClick(DialogInterface dialog,
										int id) {
									Intent browse = new Intent(
											Intent.ACTION_VIEW,
											Uri.parse("https://play.google.com/store/apps/"));
									startActivity(browse);
									// moveTaskToBack(true);
								}
							})
					.setNegativeButton("Hayır",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									yemek.this.finish();
								}
							});
			AlertDialog EskiVersiyonalert = eskiversiyon.create();
			return EskiVersiyonalert;

		case ILETISIM: // Menüdeki iletişim için alertdialog
			AlertDialog.Builder Iletisim = new AlertDialog.Builder(this);
			Iletisim.setMessage("Hangi Birime Ulaşmak İstersiniz...")
					.setCancelable(true)
					// geri tuÅŸunun fonksiyonunu iptal ediyor...
					.setPositiveButton("Bilgi Ä°ÅŸlem",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									Intent Browser = new Intent(
											Intent.ACTION_DIAL, Uri
													.parse("tel:03842281008"));
									startActivity(Browser);
								}
							})
					.setNegativeButton("Öğrenci İşleri",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									Intent Browser1 = new Intent(
											Intent.ACTION_DIAL, Uri
													.parse("tel:03842281020"));
									startActivity(Browser1);
								}
							})
					.setNeutralButton("Rektörlük",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									Intent Browser2 = new Intent(
											Intent.ACTION_DIAL, Uri
													.parse("tel:03842281000"));
									startActivity(Browser2);
								}
							});
			AlertDialog iletisimalert = Iletisim.create();
			iletisimalert.show();

		}
		return dialog;

	}

 

veri alırken bağlantım bu 

	public static String postFromInternet(String url,CookieStore cookieTut) {
		String response_str = null;

		try {
			HttpParams params = new BasicHttpParams();
			params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_1);
			DefaultHttpClient httpclient = new DefaultHttpClient(params);
			HttpPost request = new HttpPost(url);
			httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,"Android");
			
			ResponseHandler<String> responseHandler = new BasicResponseHandler();
			httpclient.setCookieStore(cookieTut);
			response_str = httpclient.execute(request, responseHandler);
			
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return response_str;
	}

 

 

Karşılaştığım hata

09-17 12:19:05.567: I/burdayım(3682): 30
09-17 12:19:05.727: I/burdayım(3682): 2
09-17 12:19:05.937: I/Choreographer(3682): Skipped 33 frames!  The application may be doing too much work on its main thread.
09-17 12:19:06.186: I/Choreographer(3682): Skipped 34 frames!  The application may be doing too much work on its main thread.
09-17 12:19:08.477: D/dalvikvm(3682): GC_CONCURRENT freed 184K, 4% free 8608K/8903K, paused 15ms+21ms, total 122ms
09-17 12:19:09.617: W/System.err(3682): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
09-17 12:19:09.617: W/System.err(3682): 	at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:146)
09-17 12:19:09.627: W/System.err(3682): 	at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
09-17 12:19:09.627: W/System.err(3682): 	at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388)
09-17 12:19:09.649: W/System.err(3682): 	at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165)
09-17 12:19:09.667: W/System.err(3682): 	at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
09-17 12:19:09.667: W/System.err(3682): 	at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
09-17 12:19:09.677: W/System.err(3682): 	at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
09-17 12:19:09.707: W/System.err(3682): 	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
09-17 12:19:09.747: W/System.err(3682): 	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:653)
09-17 12:19:09.747: W/System.err(3682): 	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
09-17 12:19:09.797: W/System.err(3682): 	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
09-17 12:19:09.807: W/System.err(3682): 	at com.dogandroid.kastamonuuniversitesi.baglantilar.postFromInternet(baglantilar.java:125)
09-17 12:19:09.807: W/System.err(3682): 	at com.dogandroid.kastamonuuniversitesi.yemek$LongOperation.doInBackground(yemek.java:104)
09-17 12:19:09.807: W/System.err(3682): 	at com.dogandroid.kastamonuuniversitesi.yemek$LongOperation.doInBackground(yemek.java:1)
09-17 12:19:09.817: W/System.err(3682): 	at android.os.AsyncTask$2.call(AsyncTask.java:287)
09-17 12:19:09.817: W/System.err(3682): 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-17 12:19:09.847: W/System.err(3682): 	at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-17 12:19:09.867: W/System.err(3682): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
09-17 12:19:09.867: W/System.err(3682): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-17 12:19:09.897: W/System.err(3682): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-17 12:19:09.917: W/System.err(3682): 	at java.lang.Thread.run(Thread.java:856)
09-17 12:19:09.926: W/dalvikvm(3682): threadid=11: thread exiting with uncaught exception (group=0x40a122a0)
09-17 12:19:10.137: E/AndroidRuntime(3682): FATAL EXCEPTION: AsyncTask #1
09-17 12:19:10.137: E/AndroidRuntime(3682): java.lang.RuntimeException: An error occured while executing doInBackground()
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at android.os.AsyncTask$3.done(AsyncTask.java:299)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at java.lang.Thread.run(Thread.java:856)
09-17 12:19:10.137: E/AndroidRuntime(3682): Caused by: java.lang.NullPointerException: println needs a message
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at android.util.Log.println_native(Native Method)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at android.util.Log.i(Log.java:159)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at com.dogandroid.kastamonuuniversitesi.yemek$LongOperation.doInBackground(yemek.java:105)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at com.dogandroid.kastamonuuniversitesi.yemek$LongOperation.doInBackground(yemek.java:1)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at android.os.AsyncTask$2.call(AsyncTask.java:287)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-17 12:19:10.137: E/AndroidRuntime(3682): 	... 5 more

 

9 Görüntülenme

0 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.