by

Thank the author with a small contribution using PayPal.

0
52 Views
1 Badge
Specified
Popularity: 11913rd place
Created
Modified Feb 2, 2014
This snippet is Public
No tags for this snippet yet.
LanguageJava
SourceGithub

02012014 soru-cevap

02012014 soru-cevap: 
YayinAkisi.java
post this code
<iframe id="embedFrame" style="width:600px; height:300px;" src="http://www.snip2code.com/Embed/25811/02012014-soru-cevap"></iframe>
Click on the embed code to copy it into your clipboard Width:Height:
Leave empty to retrieve all the content First Line:Last Line:
package com.example.dene;

import org.json.JSONObject;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class YayinAkisi extends Activity {
	private Button pzt;
	private Button sal;

	// url yi çagıralım
	private static final String url[] = {
		"http://api.learn2crack.com/android/jsonos/",
		"http://site.com/pazartesiicinjson",
		"http://site.com/saliicinjson"
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.yayin_akisi);

		pzt = (Button) findViewById(R.id.button4);
		pzt.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				new JSONParse().execute(url[1]);
			}
		});

		sal = (Button) findViewById(R.id.button5);
		sal.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				//url[] dizisinden uygun
				//olan elemanı çağırırsınız
				new JSONParse().execute(url[2]);
			}
		});
	}

	private class JSONParse extends AsyncTask<String, String, JSONObject> {
		@Override
		protected JSONObject doInBackground(String... args) {
			JSONParser jParser = new JSONParser();
			// Getting JSON from URL
			//parametre olan args, String tipinde bir dizi olarak
			//geldiğinden args[0] ile ilk elemanını alırız
			JSONObject json = jParser.getJSONFromUrl(args[0]);
			return json;
		}
	}
}

If you want to be updated about similar snippets, Sign in and follow our Channels
Originally posted on https://gist.github.com/8769250