<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mehmet Ethem SULAN</title>
	<atom:link href="http://www.ethemsulan.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ethemsulan.com</link>
	<description>Bir başka WordPress sitesi</description>
	<lastBuildDate>Fri, 09 Dec 2011 12:20:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to call An Android Activity class from non-activity class</title>
		<link>http://www.ethemsulan.com/2011/12/how-to-call-an-android-activity-class-from-non-activity-class.html</link>
		<comments>http://www.ethemsulan.com/2011/12/how-to-call-an-android-activity-class-from-non-activity-class.html#comments</comments>
		<pubDate>Wed, 07 Dec 2011 21:52:40 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1136</guid>
		<description><![CDATA[nullpointerexception non activity class hatası ile karşılaştığınızda aşağıdaki şekıilde çözebilirsiniz. Android içinde normal bir Java(Non-Activity and Non-View) sınıfından herhangi bir Activity çağırmak istediğimizde aşağıdaki gibi iki şekilde çağırabiliriz. 1. Context göndereceğimiz sınıfın yapıcısında this ile göndermektir. MyMainActivity.java import android.app.Activity; import android.content.Context; import android.os.Bundle; public class MyMainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { [...]]]></description>
			<content:encoded><![CDATA[<p><strong>nullpointerexception non activity class</strong> hatası ile karşılaştığınızda aşağıdaki şekıilde çözebilirsiniz.<br />
<strong>Android</strong> içinde normal bir <strong>Java(Non-Activity and Non-View)</strong> sınıfından herhangi bir <strong>Activity</strong> çağırmak istediğimizde aşağıdaki gibi iki şekilde çağırabiliriz.</p>
<p>1. <strong>Context</strong> göndereceğimiz sınıfın yapıcısında <strong>this</strong> ile göndermektir.</p>
<p>MyMainActivity.java</p>
<pre class="brush: java;">
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

public class MyMainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MyTestClass myTestClass=new MyTestClass(this);
        myTestClass.startSecondActivity();
    }
}
</pre>
<p>MyTestClass.java</p>
<pre class="brush: java;">
import android.content.Context;
import android.content.Intent;

public class MyTestClass {

	Context context;

	public MyTestClass(Context context) {
		super();
		this.context = context;
	}
	public void startSecondActivity()
	{
		Intent intent=new Intent(context, SecondActivity.class);
		context.startActivity(intent);
	}

}
</pre>
<p>SecondActivity.java</p>
<pre class="brush: java;">
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class SecondActivity extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Toast.makeText(getApplicationContext(), &quot;Second activity&quot;, Toast.LENGTH_LONG).show();
	}

}
</pre>
<p>2. yol ise <strong>intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)</strong>; şeklinde <strong>SecondActivity</strong> i yeni bir task ile başlatmaktır. Bu şekilde yeni task ile başlattığımız da hem <strong>MyTestClass myTestClass=new MyTestClass(this);</strong> hem de <strong>MyTestClass myTestClass=new MyTestClass(getApplicationContext());</strong> start edebiliyoruz.</p>
<p>MyMainActivity.java</p>
<pre class="brush: java;">
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

public class MyMainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MyTestClass myTestClass=new MyTestClass(getApplicationContext());
        myTestClass.startSecondActivity();
    }
}
</pre>
<p>MyTestClass.java</p>
<pre class="brush: java;">
import android.content.Context;
import android.content.Intent;

public class MyTestClass {

	Context context;

	public MyTestClass(Context context) {
		super();
		this.context = context;
	}
	public void startSecondActivity()
	{
		Intent intent=new Intent(context, SecondActivity.class);
//Yeni task ile başlattık.
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		context.startActivity(intent);
	}

}
</pre>
<p>SecondActivity.java</p>
<pre class="brush: java;">
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class SecondActivity extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Toast.makeText(getApplicationContext(), &quot;Second activity&quot;, Toast.LENGTH_LONG).show();
	}

}
</pre>
<p>AndroidManifest.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com.call&quot;
    android:versionCode=&quot;1&quot;
    android:versionName=&quot;1.0&quot; &gt;

    &lt;uses-sdk android:minSdkVersion=&quot;4&quot; /&gt;

    &lt;application
        android:icon=&quot;@drawable/ic_launcher&quot;
        android:label=&quot;@string/app_name&quot; &gt;
        &lt;activity
            android:label=&quot;@string/app_name&quot;
            android:name=&quot;.MyMainActivity&quot; &gt;
            &lt;intent-filter &gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;activity android:name=&quot;SecondActivity&quot;&gt;&lt;/activity&gt;
    &lt;/application&gt;

&lt;/manifest&gt;
</pre>
<p><a href="http://hotfile.com/dl/137081473/97da61d/CallActivity.zip.html">Download CallActivity.zip source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/12/how-to-call-an-android-activity-class-from-non-activity-class.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using KSOAP2 for android, and parsing SOAP WSDL output data</title>
		<link>http://www.ethemsulan.com/2011/11/using-ksoap2-for-android-and-parsing-soap-wsdl-output-data.html</link>
		<comments>http://www.ethemsulan.com/2011/11/using-ksoap2-for-android-and-parsing-soap-wsdl-output-data.html#comments</comments>
		<pubDate>Mon, 07 Nov 2011 01:08:48 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1128</guid>
		<description><![CDATA[Android ile KSOAP2 kullanarak SOAP Web Serviceden data çekmeye çalışırken karşılaştığım sorunu çözdükten sonra paylaşmaya çalıştım. En önemli sorun When Parsing the Soap response problem Android Developer grubuna sorulan sorudur. Kod içinde Log.e(&#34;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#34;, &#34;Root elemtn body: &#34;+soapObjectResultRoot.toString()); satırındaki outputa bakarsanız hiçbir formata uymayan bir data var ve o datayı parse etmek indexOf() metodu ile ancak [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Android</strong> ile <a href="http://code.google.com/p/ksoap2-android/">KSOAP2</a> kullanarak <strong>SOAP Web Service</strong>den data çekmeye çalışırken karşılaştığım sorunu çözdükten sonra paylaşmaya çalıştım. En önemli sorun <a href="http://groups.google.com/group/android-developers/browse_thread/thread/9b59620ad4aa3103#">When Parsing the Soap response problem</a> <strong>Android Developer</strong> grubuna sorulan sorudur. Kod içinde
<pre class="brush: java;">Log.e(&quot;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&quot;, &quot;Root elemtn body: &quot;+soapObjectResultRoot.toString());</pre>
<p> satırındaki outputa bakarsanız hiçbir formata uymayan bir data var ve o datayı parse etmek indexOf() metodu ile ancak yapılabiliyordu. DDMS e bakarsanız
<pre class="brush: java;">Root elemtn body: GetGeoIPContextResponse{GetGeoIPContextResult=anyType{ReturnCode=1; IP=78.175.34.228; ReturnCodeDetails=Success; CountryName=Turkey; CountryCode=TUR; }; }
</pre>
<p> şeklinde saçma bir data görürsünüz. Bunun sebebi <strong>bodyIn</strong> ile sadece <strong>Root Element</strong> alınmasıdır. Yani çözüm önce rootu almak sonra istenilen result metodunundaki propertye erişmektir.</p>
<pre class="brush: java;">
        	SoapObject soapObjectResultRoot=(SoapObject) soaSerializationEnvelope.bodyIn;
        	Log.e(&quot;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&quot;, &quot;Root elemtn body: &quot;+soapObjectResultRoot.toString());
        	SoapObject soapObjectGetProperty=(SoapObject) soapObjectResultRoot.getProperty(&quot;GetGeoIPContextResult&quot;);
</pre>
<p>Bu <a href="http://www.webservicex.net/geoipservice.asmx?op=GetGeoIPContext">linkte-GetGeoIPContext</a> hangi metodu ve getProperty() ile hangi değerlere erişeceğimizi <strong>SOAP</strong> içinde yazıyor.<br />
Uyarı örnek yapacağınız web servisi önce çalışıp çalışmadığını kontrol edin. Mesela şu anda <a href="http://www.webservicex.net/ws/WSDetails.aspx?CATID=12&#038;WSID=63">Translation Engine</a>   çalışmıyor ve ben de bunun üzerinden deneme yapıyordum <img src='http://www.ethemsulan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
1. <strong>ksoap2-android-assembly-2.4-jar-with-dependencies.jar</strong> indirdikten sonra <strong>assets</strong> içine atıp sonra sağ tıklayıp <strong>Build path->Add to build path</strong> tıklamanız yeterlidir. Ya da <strong>lib</strong> isminde bir klasör oluşturup onun altında atıp aynı şekilde sağ tıklayıp <strong>Build path->Add to build path</strong> ekletebilirisniz.<br />
2. Erişeceğiniz <strong>http://www.webservicex.net/geoipservice.asmx?WSDL</strong> deki <strong>WSDL</strong> silip var olan public metodlarını iyice incelemektir. Sonra istediğinizi kullanabilirisniz.<br />
3. <strong>AndroidManifest.xml</strong> içinde
<pre class="brush: java;">&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;</pre>
<p> ekleyin.<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/build.png"><img src="http://www.ethemsulan.com/wp-content/uploads/build-300x163.png" alt="" title="build" width="300" height="163" class="alignnone size-medium wp-image-1129" /></a><br />
<a href="http://www.ethemsulan.com/wp-content/uploads/output1.png"><img src="http://www.ethemsulan.com/wp-content/uploads/output1-180x300.png" alt="" title="output" width="180" height="300" class="alignnone size-medium wp-image-1130" /></a></p>
<p>AndroidSoapActivity.java</p>
<pre class="brush: java;">
package com.androidsoap;

import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class AndroidSoapActivity extends Activity {

	final static String NAMESPACE = &quot;http://www.webservicex.net/&quot;;
	final static String METHOD_NAME = &quot;GetGeoIPContext&quot;;
	final static String SOAP_ACTION = &quot;http://www.webservicex.net/GetGeoIPContext&quot;;
	final static String URL = &quot;http://www.webservicex.net/geoipservice.asmx?WSDL&quot;;

	TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        textView=(TextView) findViewById(R.id.textView1);
        SoapObject reSoapObject = new SoapObject(NAMESPACE, METHOD_NAME);
//Egerki sorgu çekecekseniz o zaman reSoapObject.addProperty(name,value); şeklinde değer eklemelisiniz. O da SOAP içinde belirtiliyor.
        SoapSerializationEnvelope soaSerializationEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        soaSerializationEnvelope.dotNet = true;
        soaSerializationEnvelope.setOutputSoapObject(reSoapObject);
        HttpTransportSE httpTransportSE = new HttpTransportSE(URL);
        int returnCode = 0;
        String ip = null, returnCodeDetail = null,countryName = null, countryCode = null;
        try {
        	httpTransportSE.call(SOAP_ACTION, soaSerializationEnvelope);
//Root elemente erişiyoruz.
        	SoapObject soapObjectResultRoot=(SoapObject) soaSerializationEnvelope.bodyIn;
        	Log.e(&quot;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&quot;, &quot;Root elemtn body: &quot;+soapObjectResultRoot.toString());
//Root elementin altındaki erişeceğimiz metodun ..Result ile biten değerine erişiyoruz. Mesela METHOD_NAME = &quot;GetGeoIPContext&quot;;
//Aşağıdaki metod ve parametre değerleri bulinkte açıklıyor zaten: http://www.webservicex.net/geoipservice.asmx?op=GetGeoIPContext
        	SoapObject soapObjectGetProperty=(SoapObject) soapObjectResultRoot.getProperty(&quot;GetGeoIPContextResult&quot;);
        	returnCode=Integer.parseInt(soapObjectGetProperty.getProperty(&quot;ReturnCode&quot;).toString());
        	ip=soapObjectGetProperty.getProperty(&quot;IP&quot;).toString();
        	returnCodeDetail=soapObjectGetProperty.getProperty(&quot;ReturnCodeDetails&quot;).toString();
        	countryName=soapObjectGetProperty.getProperty(&quot;CountryName&quot;).toString();
        	countryCode=soapObjectGetProperty.getProperty(&quot;CountryCode&quot;).toString();
        } catch (IOException e) {
        e.printStackTrace();
        } catch (XmlPullParserException e) {
        e.printStackTrace();
        }

        textView.setText(&quot;Return code --&gt; &quot;+returnCode+&quot; \nIP --&gt; &quot;+ip+&quot; \nReturn code details --&gt; &quot;+returnCodeDetail+&quot; \nCountry name --&gt; &quot;+countryName+&quot; \nCountry code --&gt; &quot;+countryCode);

    }
}
</pre>
<p>main.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:orientation=&quot;vertical&quot; &gt;

    &lt;TextView
        android:id=&quot;@+id/textView1&quot;
        android:layout_width=&quot;230dp&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;TextView&quot; /&gt;

&lt;/LinearLayout&gt;
</pre>
<p>AndroidManifest.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com.androidsoap&quot;
    android:versionCode=&quot;1&quot;
    android:versionName=&quot;1.0&quot; &gt;

    &lt;uses-sdk android:minSdkVersion=&quot;4&quot; /&gt;
    &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;

    &lt;application
        android:icon=&quot;@drawable/ic_launcher&quot;
        android:label=&quot;@string/app_name&quot; &gt;
        &lt;activity
            android:label=&quot;@string/app_name&quot;
            android:name=&quot;.AndroidSoapActivity&quot; &gt;
            &lt;intent-filter &gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;

&lt;/manifest&gt;
</pre>
<p><a href="http://hotfile.com/dl/137081425/865d391/AndroidSoapSam.zip.html">Download AndroidSoapSam.zip srouce code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/11/using-ksoap2-for-android-and-parsing-soap-wsdl-output-data.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android Activity startActivityForResult sample</title>
		<link>http://www.ethemsulan.com/2011/10/android-activity-startactivityforresult-sample.html</link>
		<comments>http://www.ethemsulan.com/2011/10/android-activity-startactivityforresult-sample.html#comments</comments>
		<pubDate>Fri, 28 Oct 2011 16:05:56 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1123</guid>
		<description><![CDATA[Android içinde startActivityForResult() metodu ile başlatılan sub activitynin normal kapanıp kapanmadığına göre işlem yapabiliyoruz. Mesela devicedaki Back buttonuna basarak beklenmedik şekilde activity sonlandirabilir. Bazı durumlarda buna göre işlem yapmak zorunda kalıyoruz. StartForResultActivity.java package com.start.result; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class StartForResultActivity [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Android</strong> içinde <strong>startActivityForResult() metod</strong>u ile başlatılan sub activitynin normal kapanıp kapanmadığına göre işlem yapabiliyoruz. Mesela devicedaki <strong>Back</strong> buttonuna basarak beklenmedik şekilde activity sonlandirabilir. Bazı durumlarda buna göre işlem yapmak zorunda kalıyoruz.</p>
<p>StartForResultActivity.java</p>
<pre class="brush: java;">
package com.start.result;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class StartForResultActivity extends Activity {
	Button button1_ok;
	private static final int SHOW_SUBACTIVITY = 1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        button1_ok=(Button) findViewById(R.id.button1);

        button1_ok.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(StartForResultActivity.this, SecondActivity.class);
				startActivityForResult(intent, SHOW_SUBACTIVITY);
			}
		});
    }
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);

		switch (requestCode) {
		case 1:
//Second activity normal olarak sonlanirsa RESULT_OK degeri döner.
			if(resultCode==Activity.RESULT_OK)
			{
				String string=data.getStringExtra(&quot;ethem&quot;);
				Toast.makeText(getApplicationContext(), &quot;Inputed text: &quot;+string, Toast.LENGTH_SHORT).show();
//Second activity beklendmedik sekilde kapanirsa(Mesela cihazdaki back buttonuna tikalnirsa) RESULT_CANCELED degeri doner.
			}else if(resultCode==Activity.RESULT_CANCELED){
				Toast.makeText(getApplicationContext(), &quot;Beklenmedik sekilde second activity sonlandi&quot;, Toast.LENGTH_SHORT).show();
			}

			break;
		}

	}

}
</pre>
<p>SecondActivity.java</p>
<pre class="brush: java;">
package com.start.result;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class SecondActivity extends Activity{

	Button button;
	EditText editText;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.second);
		button=(Button) findViewById(R.id.button1);
		editText=(EditText) findViewById(R.id.editText1);

		button.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
//Finish buttonuna tıklanarak activity sonlanirsa(yani beklediğimiz gibi) o zaman setResult(RESULT_OK, intent); değer dönderiyoruz StartForResultActivity activiysine.
				Intent intent=new Intent();
				intent.putExtra(&quot;ethem&quot;, editText.getText().toString());
				setResult(RESULT_OK, intent);
				finish();

			}
		});

	}

}
</pre>
<p>main.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:orientation=&quot;horizontal&quot;&gt;

    &lt;Button android:text=&quot;Open Second Activity&quot; android:id=&quot;@+id/button1&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;&gt;&lt;/Button&gt;
&lt;/LinearLayout&gt;
</pre>
<p>second.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout
  xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  android:orientation=&quot;vertical&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;&gt;
    &lt;EditText android:layout_width=&quot;match_parent&quot; android:id=&quot;@+id/editText1&quot; android:layout_height=&quot;wrap_content&quot;&gt;
        &lt;requestFocus&gt;&lt;/requestFocus&gt;
    &lt;/EditText&gt;
    &lt;Button android:text=&quot;Finish&quot; android:id=&quot;@+id/button1&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;&gt;&lt;/Button&gt;

&lt;/LinearLayout&gt;
</pre>
<p><a href="http://hotfile.com/dl/137081357/fdd04e5/StartForResult.zip.html">Download StartForResult.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/10/android-activity-startactivityforresult-sample.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Value of variables not showing eclipse on java debug mode</title>
		<link>http://www.ethemsulan.com/2011/10/value-of-variables-not-showing-eclipse-on-java-debug.html</link>
		<comments>http://www.ethemsulan.com/2011/10/value-of-variables-not-showing-eclipse-on-java-debug.html#comments</comments>
		<pubDate>Tue, 25 Oct 2011 10:24:05 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Genel Bilgiler]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1116</guid>
		<description><![CDATA[When you want to debug your java projects, if you can not see the values of variables, you can solve this problem, by below solution. 1. Got to Window -> Preferences -> Java -> Debug -> Detail Formatters 2. Go to under the &#8220;Show variable details(&#8216;toString()&#8217; value): &#8221; then check &#8220;As the label for variables [...]]]></description>
			<content:encoded><![CDATA[<p>When you want to <strong>debug your java projects</strong>, if you <strong>can not see the values of variables</strong>, you can solve this problem, by below solution.</p>
<p>1. Got to <strong>Window -> Preferences -> Java -> Debug -> Detail Formatters</strong> </p>
<p>2. Go to under the &#8220;<strong>Show variable details(&#8216;toString()&#8217; value):</strong> &#8221; then check &#8220;<strong>As the label for variables with detail formatters</strong>&#8220;.</p>
<p>3. Clik ok button, then finish operation.<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/detail.png"><img src="http://www.ethemsulan.com/wp-content/uploads/detail-266x300.png" alt="" title="detail" width="266" height="300" class="alignnone size-medium wp-image-1117" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/10/value-of-variables-not-showing-eclipse-on-java-debug.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android ListPreference OnPreferenceChangeListener Sample</title>
		<link>http://www.ethemsulan.com/2011/10/android-listpreference-onpreferencechangelistener-sample.html</link>
		<comments>http://www.ethemsulan.com/2011/10/android-listpreference-onpreferencechangelistener-sample.html#comments</comments>
		<pubDate>Fri, 21 Oct 2011 21:20:36 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1101</guid>
		<description><![CDATA[Android ile PreferenceScreen içinde ListPreference içinde seçilen değer değiştiğinde gerçekleşen olay için basit bir örnek yazdım. findViewById() metoduna benzer bir erişim metodu var. listPreference=(ListPreference) findPreference(&#34;customPreferences&#34;); PreferenceScreen içinde aşağıdaki resimde görüldüğü gibi bazı özellikler tanımlayabiliyoruz. Android settings bununla yazılmış. Çalıştırınca MyPreferences.java package com.preference.sam; import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.Preference.OnPreferenceChangeListener; import android.util.Log; import [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Android</strong> ile <strong>PreferenceScreen</strong> içinde <strong>ListPreference</strong> içinde seçilen değer değiştiğinde gerçekleşen olay için basit bir örnek yazdım. findViewById() metoduna benzer bir erişim metodu var.</p>
<pre class="brush: java;">listPreference=(ListPreference) findPreference(&quot;customPreferences&quot;);</pre>
<p><strong>PreferenceScreen</strong> içinde aşağıdaki resimde görüldüğü gibi bazı özellikler tanımlayabiliyoruz. Android settings bununla yazılmış.<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/create_pref.png"><img src="http://www.ethemsulan.com/wp-content/uploads/create_pref-277x300.png" alt="" title="create_pref" width="277" height="300" class="alignnone size-medium wp-image-1102" /></a><br />
Çalıştırınca<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/pref_outp.png"><img src="http://www.ethemsulan.com/wp-content/uploads/pref_outp-180x300.png" alt="" title="pref_outp" width="180" height="300" class="alignnone size-medium wp-image-1103" /></a><br />
MyPreferences.java</p>
<pre class="brush: java;">
package com.preference.sam;

import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceChangeListener;
import android.util.Log;
import android.widget.Toast;

public class MyPreferences extends PreferenceActivity {

	ListPreference listPreference;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//R.xml.pref ekliyoruz.
		addPreferencesFromResource(R.xml.pref);
//android:key=&quot;customPreferences&quot; xml/pref.xml içindeki isim
		listPreference=(ListPreference) findPreference(&quot;customPreferences&quot;);
		listPreference.setOnPreferenceChangeListener(onPreferenceChangeListener);

	}

	OnPreferenceChangeListener onPreferenceChangeListener=new OnPreferenceChangeListener() {

		@Override
		public boolean onPreferenceChange(Preference preference, Object newValue) {
//Seçilen isme ait numara toast olarak görünüyor ve toast indeksi de log attiriyorum.
//pref.xml içinde android:entries=&quot;@array/names&quot; ile görünecek bir dizi atiyoruz ve
//android:entryValues=&quot;@array/stud_num&quot; kod ile de o diziye ait değerleri yazıyoruz.
//Bu iki dizi values/strings.xml içinde String array olarak tanımlanmıştır.
			Toast.makeText(getApplicationContext(), &quot;Secilen ogrencinin okul numarasi : &quot;+newValue, Toast.LENGTH_LONG).show();
			int index=listPreference.findIndexOfValue((String) newValue);
			Log.e(&quot;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&quot;, &quot;Index of selected value :&quot; + index);
			return false;
		}
	};

}
</pre>
<p>pref.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;PreferenceScreen xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; &gt;

    &lt;PreferenceCategory android:title=&quot;Categori 1&quot;&gt;
    	&lt;ListPreference android:title=&quot;List Of Name&quot;
    		android:key=&quot;customPreferences&quot;
    		android:entries=&quot;@array/names&quot;
    		android:entryValues=&quot;@array/stud_num&quot;&gt;
    	&lt;/ListPreference&gt;
    &lt;/PreferenceCategory&gt;

&lt;/PreferenceScreen&gt;
</pre>
<p>strings.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;resources&gt;

    &lt;string name=&quot;hello&quot;&gt;Hello World, PreferenceSamActivity!&lt;/string&gt;
    &lt;string name=&quot;app_name&quot;&gt;PreferenceSam&lt;/string&gt;
    &lt;string-array name=&quot;names&quot;&gt;
        &lt;item &gt;Ethem&lt;/item&gt;
        &lt;item &gt;Isil&lt;/item&gt;
    &lt;/string-array&gt;
    &lt;string-array name=&quot;stud_num&quot;&gt;
        &lt;item &gt;060401029&lt;/item&gt;
        &lt;item &gt; 1121000300&lt;/item&gt;
    &lt;/string-array&gt;

&lt;/resources&gt;
</pre>
<p>Bunu main activity yaptım.<br />
AndroidManifest.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com.preference.sam&quot;
    android:versionCode=&quot;1&quot;
    android:versionName=&quot;1.0&quot; &gt;

    &lt;application
        android:icon=&quot;@drawable/ic_launcher&quot;
        android:label=&quot;@string/app_name&quot; &gt;
        &lt;activity android:name=&quot;MyPreferences&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot;/&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;/&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;/application&gt;

&lt;/manifest&gt;
</pre>
<p><a href="http://hotfile.com/dl/137081229/49614c5/PreferenceSam.zip.html">Download PreferenceSam.zip</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/10/android-listpreference-onpreferencechangelistener-sample.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android SharedPreferences Sample</title>
		<link>http://www.ethemsulan.com/2011/10/android-sharedpreferences-sample.html</link>
		<comments>http://www.ethemsulan.com/2011/10/android-sharedpreferences-sample.html#comments</comments>
		<pubDate>Thu, 13 Oct 2011 17:36:24 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1092</guid>
		<description><![CDATA[Android içinde SahredPreferences verileri tutumak için kullanışlı bir yapıdır. Emülatörde /data/data/com.share.preferance/shared_prefs/ethem.xml olarak bakabilirisniz. Bazı uygulamalarda datalarınızı xml olarak tutma ihtiyacı için geliştirilmiş bir yapıtır. Buraya boolean, string, int, long ve float gibi veri tiplerini ekleyebilirsiniz. Aşağıdaki kod ile her activity create edildiğinde önceki verileri siliyorum. shEditor=sharedPreferences.edit(); shEditor.clear(); shEditor.commit(); ethem.xml dosyasını export etmek için aşağıdaki resimde [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Android</strong> içinde <strong>SahredPreferences</strong> verileri tutumak için kullanışlı bir yapıdır. Emülatörde <strong>/data/data/com.share.preferance/shared_prefs/ethem.xml</strong> olarak bakabilirisniz. Bazı uygulamalarda datalarınızı <strong>xml</strong> olarak tutma ihtiyacı için geliştirilmiş bir yapıtır. Buraya boolean, string, int, long ve float gibi veri tiplerini ekleyebilirsiniz. Aşağıdaki kod ile her activity create edildiğinde önceki verileri siliyorum.</p>
<pre class="brush: java;">
        shEditor=sharedPreferences.edit();
        shEditor.clear();
        shEditor.commit();
</pre>
<p><a href="http://www.ethemsulan.com/wp-content/uploads/input.png"><img src="http://www.ethemsulan.com/wp-content/uploads/input-300x221.png" alt="" title="input" width="300" height="221" class="alignnone size-medium wp-image-1093" /></a><br />
ethem.xml dosyasını export etmek için aşağıdaki resimde kırmızı alanı tıklayın.<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/input2.png"><img src="http://www.ethemsulan.com/wp-content/uploads/input2-300x111.png" alt="" title="input2" width="300" height="111" class="alignnone size-medium wp-image-1094" /></a></p>
<p>İçerik te aşağıdaki gibidir.<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/input3.png"><img src="http://www.ethemsulan.com/wp-content/uploads/input3-300x128.png" alt="" title="input3" width="300" height="128" class="alignnone size-medium wp-image-1095" /></a><br />
SharePrefereanceActivity.java</p>
<pre class="brush: java;">
package com.share.preferance;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class SharePrefereanceActivity extends Activity {
	SharedPreferences sharedPreferences;
	SharedPreferences.Editor shEditor;
	Button button_save, button_show;
	static final private int share_pref_dialog = 1;
	StringBuilder stringBuilder;
	EditText editText_name, editText_age, editText_address;
	static int i=1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        button_save=(Button) findViewById(R.id.button1_save);
        button_show=(Button) findViewById(R.id.button2_show);
        editText_name=(EditText) findViewById(R.id.editText1_name);
        editText_age=(EditText) findViewById(R.id.editText2_age);
        editText_address=(EditText) findViewById(R.id.editText3_address);

        stringBuilder=new StringBuilder();
//ethem isminde bir xml oluşturuyor ve .edit() mtodu ile ekleme,silme ve güncelleme izni veriyoruz.
        sharedPreferences=getSharedPreferences(&quot;ethem&quot;, Activity.MODE_PRIVATE);
        shEditor=sharedPreferences.edit();
//Bu metod ile daha önceki kayıtları siliyoruz.
        shEditor.clear();
        shEditor.commit();
        button_save.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				int age=0;
				String name=editText_name.getText().toString();
				if(editText_age.getText().toString().length()&gt;0)
				{
				age=Integer.parseInt(editText_age.getText().toString());
				}
				String address=editText_address.getText().toString();
				if(name.length()&gt;0 &amp;&amp; age&gt;0 &amp;&amp; address.length()&gt;0)
				{
				create_share_preferences(name, age, address);
				}else{
					Toast.makeText(getApplicationContext(), &quot;Check your inputs&quot;, Toast.LENGTH_LONG).show();
				}
			}
		});

        button_show.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
//BUtton tıklanınca onCreateDialog() metodu içindeki dialog açılıyor.
				showDialog(share_pref_dialog);

			}
		});

    }
	private String reterieve_share_preferences() {
//.xml içindeki bütün kayıtları stringbuildera atıyoruz.
		 Map&lt;String, ?&gt; all_record = sharedPreferences.getAll();
		 Set set=all_record.entrySet();
		 Iterator it=set.iterator();
		 while (it.hasNext()) {
			 	Map.Entry map =(Map.Entry)it.next();
				stringBuilder.append(map.getKey()+&quot; : &quot;+map.getValue()+&quot;\n&quot;);
				if(i%3==0)
				{
					stringBuilder.append(&quot;************\n&quot;);
				}
				i++;
		}

		return stringBuilder.toString();
	}
	private void create_share_preferences(String name,int age, String address) {
//Girilen kayıtları xml olarak kayıdediyor.
		shEditor.putString(&quot;name&quot;, name);
        shEditor.putInt(&quot;age&quot;, age);
        shEditor.putString(&quot;address&quot;, address);
        shEditor.commit();
        editText_name.setText(&quot;&quot;);
        editText_age.setText(&quot;&quot;);
        editText_address.setText(&quot;&quot;);
	}
	@Override
	protected Dialog onCreateDialog(int id) {

		Builder alBuilder;
		switch(id) {
		case (share_pref_dialog) :
			alBuilder = new AlertDialog.Builder(this);
			alBuilder.setTitle(&quot;Do you want to show all records&quot;).
			setCancelable(false).setPositiveButton(&quot;Yes&quot;,
							new DialogInterface.OnClickListener() {

								@Override
								public void onClick(DialogInterface dialog,
										int which) {
									dialog.cancel();
//ok seçilirse toast ile ekranda gösteriyorum.
									Toast.makeText(getApplicationContext(), reterieve_share_preferences(), Toast.LENGTH_LONG).show();

								}
							}).setNegativeButton(&quot;No&quot;,
							new DialogInterface.OnClickListener() {

								@Override
								public void onClick(DialogInterface dialog,
										int which) {
									finish();

								}
							});
		return alBuilder.create();
		}
		return super.onCreateDialog(id);

	}
}
</pre>
<p>main.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
    &lt;TableLayout android:layout_width=&quot;fill_parent&quot; android:id=&quot;@+id/tableLayout1&quot; android:layout_height=&quot;wrap_content&quot;&gt;
        &lt;TableRow android:id=&quot;@+id/tableRow1&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;&gt;
            &lt;TextView android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:text=&quot;Name :&quot; android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; android:id=&quot;@+id/textView1&quot;&gt;&lt;/TextView&gt;
            &lt;EditText android:id=&quot;@+id/editText1_name&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;&gt;
                &lt;requestFocus&gt;&lt;/requestFocus&gt;
            &lt;/EditText&gt;
        &lt;/TableRow&gt;
        &lt;TableRow android:id=&quot;@+id/tableRow2&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;&gt;
            &lt;TextView android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; android:id=&quot;@+id/textView2&quot; android:text=&quot;Age :&quot;&gt;&lt;/TextView&gt;
            &lt;EditText android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:inputType=&quot;number&quot; android:id=&quot;@+id/editText2_age&quot;&gt;&lt;/EditText&gt;
        &lt;/TableRow&gt;
        &lt;TableRow android:id=&quot;@+id/tableRow3&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;&gt;
            &lt;TextView android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; android:id=&quot;@+id/textView3&quot; android:text=&quot;Address :&quot;&gt;&lt;/TextView&gt;
            &lt;EditText android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:inputType=&quot;textPostalAddress&quot; android:id=&quot;@+id/editText3_address&quot;&gt;&lt;/EditText&gt;
        &lt;/TableRow&gt;
        &lt;TableRow android:id=&quot;@+id/tableRow4&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;&gt;
            &lt;Button android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:text=&quot;Save Input&quot; android:id=&quot;@+id/button1_save&quot;&gt;&lt;/Button&gt;
            &lt;Button android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:text=&quot;Show Records&quot; android:id=&quot;@+id/button2_show&quot;&gt;&lt;/Button&gt;
        &lt;/TableRow&gt;
    &lt;/TableLayout&gt;
&lt;/LinearLayout&gt;
</pre>
<p>Bu arada com.share.preferance paket ismini yanlış yazmışım:)</p>
<p><a href="http://hotfile.com/dl/137081104/e2d647f/SharePrefereance.zip.html">Download SharePrefereance.zip</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/10/android-sharedpreferences-sample.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android Create Customize Adapter and ListView Items</title>
		<link>http://www.ethemsulan.com/2011/09/android-create-customize-adapter-and-listview-items.html</link>
		<comments>http://www.ethemsulan.com/2011/09/android-create-customize-adapter-and-listview-items.html#comments</comments>
		<pubDate>Fri, 09 Sep 2011 17:54:12 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1085</guid>
		<description><![CDATA[Android ile Twitter&#8216;a benzer bir basit uygulama yazmaya çalıştım. Normalde uygulamaya login olurken username, profil image ve password sqlite veritabanında tutuluyor ve değerler oradan alınıyor ama örnek sade olsun diye o tarafa girmedim. Bu örneği daha iyi anlamak için Android Custom ListView Items and Adaptera bakabilirsiniz. Uygulama image, user_name ve text alanalrından oluşuyor. En son [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Android</strong> ile <strong>Twitter</strong>&#8216;a benzer bir basit uygulama yazmaya çalıştım. Normalde uygulamaya login olurken username, profil image ve password sqlite veritabanında tutuluyor ve değerler oradan alınıyor ama örnek sade olsun diye o tarafa girmedim. Bu örneği daha iyi anlamak için <a href="http://www.ethemsulan.com/2011/04/android-custom-listview-items-and-adapter.html">Android Custom ListView Items and Adapter</a>a bakabilirsiniz.</p>
<p>Uygulama image, user_name ve text alanalrından oluşuyor. <strong>En son girilen input</strong> en <strong>ListView</strong>&#8216;de en üste ekleniyor.<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/blip.png"><img src="http://www.ethemsulan.com/wp-content/uploads/blip-180x300.png" alt="" title="blip" width="180" height="300" class="alignnone size-medium wp-image-1086" /></a></p>
<p>BlipListActivity.java</p>
<pre class="brush: java;">
package com.blip.list;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class BlipListActivity extends Activity {
    private ListView listView;
    private Button button_send_blip;
    private EditText editText_input_text;
    private BlipVar blipVar_obj;
    private BlipAdapter blipAdapter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        listView=(ListView) findViewById(R.id.listView1_blip);
        button_send_blip=(Button) findViewById(R.id.button1_send);
        editText_input_text=(EditText) findViewById(R.id.editText1_input);
        Conf.arrayList.clear();

//        BlipVar object=new BlipVar();
//        object.setUser_name(&quot;mehmet&quot;);
//        object.setImage(&quot;http://www.ethemsulan.com/wp-content/themes/mahinhin/images/kelime.png&quot;);
//        object.setText(&quot;Merhaba bu bir textttir&quot;);
//		Conf.arrayList.add(object);
//Kendi adapterimizi yazdik ve listview ile ilişkilendirdik.
        blipAdapter=new BlipAdapter(this, Conf.arrayList);
        listView.setAdapter(blipAdapter);

        button_send_blip.setOnClickListener(send_blip);
    }

    OnClickListener send_blip=new OnClickListener() {

		@Override
		public void onClick(View v) {
			blipVar_obj=new BlipVar();
			blipVar_obj.setUser_name(&quot;isil&quot;);
			blipVar_obj.setImage(&quot;http://www.ethemsulan.com/wp-content/themes/mahinhin/images/kelime.png&quot;);
			blipVar_obj.setText(editText_input_text.getText().toString());
			Conf.arrayList.add(0, blipVar_obj);
//Adaptarimiza data girildiğinde kendisini güncelliyor ve girilen data hemen alta eklenir.
//Yani UI güncelleniyor.
			blipAdapter.notifyDataSetChanged();
			editText_input_text.setText(&quot;&quot;);

		}
	};
}
</pre>
<p>BlipAdapter.java</p>
<pre class="brush: java;">
package com.blip.list;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class BlipAdapter extends ArrayAdapter&lt;BlipVar&gt;{
//BlipVar nesne listesi &quot;names&quot; ekleniliyor.
	private final Activity context;
	private ArrayList&lt;BlipVar&gt; names;

	public BlipAdapter(Activity context,ArrayList&lt;BlipVar&gt; names) {
//Bu username, textview ve image için layouyt oluşrurup nasıl gösterileceğine karar veriyoruz
//R.layout.blip_adapter

		super(context, R.layout.blip_adapter, names);
		this.context = context;

		this.names = names;
	}

	static class ViewHolder {
		public ImageView imageView;
		public TextView textView_user_name,textView_body_text;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		final ViewHolder holder;

		View rowView = convertView;
		if (rowView == null) {
			LayoutInflater inflater = context.getLayoutInflater();
			rowView = inflater.inflate(R.layout.blip_adapter, null, true);
			holder = new ViewHolder();
			holder.textView_user_name = (TextView) rowView.findViewById(R.id.textView1_user_name);
			holder.imageView = (ImageView) rowView.findViewById(R.id.imageView1);
			holder.textView_body_text=(TextView) rowView.findViewById(R.id.textView1_blip_text);
			rowView.setTag(holder);
		} else {
			holder = (ViewHolder) rowView.getTag();
		}
//Gelen obje içindeki dataları set ediyor.
		BlipVar blipVar=names.get(position);

		if(blipVar!=null)
		{
			holder.textView_user_name.setText(blipVar.getUser_name());
			holder.imageView.setImageDrawable(Conf.loadImageFromURL(blipVar.getImage()));

			holder.textView_body_text.setText(blipVar.getText());
		}		

		return rowView;
	}

}
</pre>
<p>BlipVar.java</p>
<pre class="brush: java;">
package com.blip.list;

public class BlipVar {
//Adapterimizd ehang, alanalr varsa o alanalr tanimlanir.
	private String user_name,image,text;

	public String getUser_name() {
		return user_name;
	}

	public void setUser_name(String user_name) {
		this.user_name = user_name;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

}
</pre>
<p>Conf.java</p>
<pre class="brush: java;">

package com.blip.list;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.util.Log;

public class Conf {

	public static ArrayList&lt;BlipVar&gt; arrayList=new ArrayList&lt;BlipVar&gt;();

	//Internetten image cekiyor
	 public static Drawable loadImageFromURL(String url)
	    {
	    try
	    {
	    InputStream is = (InputStream) new URL(url).getContent();
	    Drawable d = Drawable.createFromStream(is, &quot;src&quot;);
	    return d;
	    }catch (Exception e) {
	    System.out.println(e);
	    return null;
	    }
	 }

	private static InputStream OpenHttpConnection(String urlString) throws IOException
    {
		//Log.d(TAG, &quot;InputStream&quot;);
		InputStream in = null;
		while(in==null){
			int response = -1;

			URL url = new URL(urlString);
			URLConnection conn = url.openConnection();

			if (!(conn instanceof HttpURLConnection)) throw new IOException(&quot;Not an HTTP connection&quot;);

            HttpURLConnection httpConn = (HttpURLConnection) conn;
            httpConn.setAllowUserInteraction(false);
            httpConn.setInstanceFollowRedirects(true);
            httpConn.setRequestMethod(&quot;GET&quot;);
            httpConn.setReadTimeout(5000);
            httpConn.setConnectTimeout(5000);
            httpConn.connect();
            response = httpConn.getResponseCode();
            if (response == HttpURLConnection.HTTP_OK) {
                in = httpConn.getInputStream();
            }
        }
        return in;
    }

}
</pre>
<p>blip_adapter.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout
  xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  android:layout_width=&quot;fill_parent&quot;
  android:layout_height=&quot;fill_parent&quot; android:orientation=&quot;vertical&quot;&gt;
    &lt;LinearLayout android:layout_width=&quot;fill_parent&quot; android:id=&quot;@+id/linearLayout1&quot; android:layout_height=&quot;wrap_content&quot; android:weightSum=&quot;1&quot; android:baselineAligned=&quot;true&quot;&gt;
        &lt;ImageView android:src=&quot;@drawable/icon&quot; android:id=&quot;@+id/imageView1&quot; android:layout_height=&quot;50dip&quot; android:layout_width=&quot;60dip&quot; android:layout_marginLeft=&quot;10dip&quot;&gt;&lt;/ImageView&gt;
        &lt;TextView android:text=&quot;TextView&quot; android:layout_width=&quot;wrap_content&quot; android:id=&quot;@+id/textView1_user_name&quot; android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; android:layout_height=&quot;fill_parent&quot; android:layout_marginLeft=&quot;50dip&quot;&gt;&lt;/TextView&gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout android:layout_width=&quot;fill_parent&quot; android:id=&quot;@+id/linearLayout2&quot; android:layout_height=&quot;wrap_content&quot; android:orientation=&quot;vertical&quot;&gt;
        &lt;TextView android:text=&quot;TextView&quot; android:layout_width=&quot;wrap_content&quot; android:id=&quot;@+id/textView1_blip_text&quot; android:layout_height=&quot;wrap_content&quot; android:textAppearance=&quot;?android:attr/textAppearanceMedium&quot; android:layout_gravity=&quot;center&quot;&gt;&lt;/TextView&gt;
    &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt;
</pre>
<p>main.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
    &lt;LinearLayout android:layout_width=&quot;fill_parent&quot; android:id=&quot;@+id/linearLayout1&quot; android:layout_height=&quot;wrap_content&quot;&gt;
        &lt;EditText android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:layout_weight=&quot;1&quot; android:id=&quot;@+id/editText1_input&quot; android:inputType=&quot;textMultiLine&quot;&gt;
            &lt;requestFocus&gt;&lt;/requestFocus&gt;
        &lt;/EditText&gt;
    &lt;/LinearLayout&gt;
    &lt;Button android:layout_gravity=&quot;right&quot; android:text=&quot;@string/send_blip&quot; android:id=&quot;@+id/button1_send&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;&gt;&lt;/Button&gt;
    &lt;ListView android:id=&quot;@+id/listView1_blip&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;&gt;&lt;/ListView&gt;
&lt;/LinearLayout&gt;
</pre>
<p>strings.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;resources&gt;
    &lt;string name=&quot;hello&quot;&gt;Hello World, BlipListActivity!&lt;/string&gt;
    &lt;string name=&quot;app_name&quot;&gt;BlipList&lt;/string&gt;
    &lt;string name=&quot;send_blip&quot;&gt;Send New Blip&lt;/string&gt;
&lt;/resources&gt;
</pre>
<p>AndroidManifest.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.blip.list&quot;
      android:versionCode=&quot;1&quot;
      android:versionName=&quot;1.0&quot;&gt;
&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;&gt;&lt;/uses-permission&gt;

    &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt;
        &lt;activity android:name=&quot;.BlipListActivity&quot;
                  android:label=&quot;@string/app_name&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;/application&gt;
&lt;/manifest&gt;
</pre>
<p><a href="http://hotfile.com/dl/137081039/eb787c2/BlipList.tar.gz.html">Download BlipList.tar.gz</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/09/android-create-customize-adapter-and-listview-items.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable Android recreate activity on Orientation Change</title>
		<link>http://www.ethemsulan.com/2011/08/disable-android-recreate-activity-on-orientation-change.html</link>
		<comments>http://www.ethemsulan.com/2011/08/disable-android-recreate-activity-on-orientation-change.html#comments</comments>
		<pubDate>Sat, 06 Aug 2011 12:28:26 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1075</guid>
		<description><![CDATA[Android cihazınızın ekranını çevirirken veya döndürürken activity yeniden create ediliyor. Aşağıdaki uygulamada bar yüklenirken çevirdiğimizde activity recreate edildiğinden yarıda kalıyor ilerleme. Yani dolmuyor. Dolması için tekrar buttona basmamız gerekiyor. OrientationSampActivity.java package com.orientation; import android.app.Activity; import android.app.ProgressDialog; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ProgressBar; public class OrientationSampActivity extends Activity { private [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Android cihazınızın</strong> ekranını çevirirken veya döndürürken <strong>activity</strong> yeniden create ediliyor. Aşağıdaki uygulamada bar yüklenirken çevirdiğimizde <strong>activity recreate</strong> edildiğinden yarıda kalıyor ilerleme. Yani dolmuyor. Dolması için tekrar buttona basmamız gerekiyor.<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/bar1.png"><img src="http://www.ethemsulan.com/wp-content/uploads/bar1-180x300.png" alt="" title="bar1" width="180" height="300" class="alignnone size-medium wp-image-1079" /></a><br />
<a href="http://www.ethemsulan.com/wp-content/uploads/bar2.png"><img src="http://www.ethemsulan.com/wp-content/uploads/bar2-180x300.png" alt="" title="bar2" width="180" height="300" class="alignnone size-medium wp-image-1080" /></a><br />
<a href="http://www.ethemsulan.com/wp-content/uploads/bar3.png"><img src="http://www.ethemsulan.com/wp-content/uploads/bar3-180x300.png" alt="" title="bar3" width="180" height="300" class="alignnone size-medium wp-image-1081" /></a><br />
OrientationSampActivity.java</p>
<pre class="brush: java;">
package com.orientation;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;

public class OrientationSampActivity extends Activity {
    private ProgressBar progressBar1;
    private Button button_bar;
    private Handler handler;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        handler=new Handler();
        progressBar1=(ProgressBar) findViewById(R.id.progressBar1);
        button_bar=(Button) findViewById(R.id.button1_bar);
        progressBar1.setProgress(0);
//Cihazinizi cevirdiginizde(oriantasyon degistiginde) activity yeniden baslatiyor
//ve bar daha once kalinan yerde kaliyor. Yani barin tamamen dolmasş icin buttona tekrar tiklamaniz lazim.
        button_bar.setOnClickListener(new Button.OnClickListener() {
			@Override
			public void onClick(View v) {
				handler.post(runaRunnable);
			}
		});
    }

    Runnable runaRunnable=new Runnable() {

		@Override
		public void run() {
			progressBar1.setProgress(progressBar1.getProgress()+1);

			if(progressBar1.getProgress()&lt;100)
			{
				handler.postDelayed(runaRunnable, 100);
			}else{
				handler.removeCallbacks(runaRunnable);
			}

		}
	};
}
</pre>
<p>main.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
    &lt;ProgressBar
    android:layout_height=&quot;wrap_content&quot;
    android:id=&quot;@+id/progressBar1&quot;
    style=&quot;?android:attr/progressBarStyleHorizontal&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_marginTop=&quot;30px&quot;&gt;
    &lt;/ProgressBar&gt;
    &lt;LinearLayout
    android:layout_width=&quot;match_parent&quot;
    android:id=&quot;@+id/linearLayout1&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_height=&quot;30dip&quot;&gt;
    &lt;/LinearLayout&gt;
    &lt;Button
    android:id=&quot;@+id/button1_bar&quot;
    android:layout_width=&quot;match_parent&quot;
    android:text=&quot;Start Bar&quot;
    android:layout_height=&quot;wrap_content&quot;&gt;
    &lt;/Button&gt;
&lt;/LinearLayout&gt;
</pre>
<p>AndroidManifest.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.orientation&quot;
      android:versionCode=&quot;1&quot;
      android:versionName=&quot;1.0&quot;&gt;

    &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt;
        &lt;activity android:name=&quot;.OrientationSampActivity&quot;
                  android:label=&quot;@string/app_name&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;/application&gt;
&lt;/manifest&gt;
</pre>
<p>Bu örneği indirip çalıştırınız ve progessbar yarıdayken cihazınızı döndürün:<a href="http://hotfile.com/dl/137080929/0894b1f/OrientationSamp.tar.html"> Download OrientationSamp</a></p>
<p><strong>Sonra aşağıdaki kodu activitye ekleyin ve çalıştırıp tekrar dönderdiğinizde activityniz yeniden create edilmiyor.</strong></p>
<pre class="brush: java;">android:configChanges=&quot;orientation|keyboardHidden&quot;</pre>
<p>AndroidManifest.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.orientation&quot;
      android:versionCode=&quot;1&quot;
      android:versionName=&quot;1.0&quot;&gt;

    &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt;
        &lt;activity android:name=&quot;.OrientationSampActivity&quot;
                  android:label=&quot;@string/app_name&quot;
                  android:configChanges=&quot;orientation|keyboardHidden&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;/application&gt;
&lt;/manifest&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/08/disable-android-recreate-activity-on-orientation-change.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get mac address, manufacturer and model of Android Device</title>
		<link>http://www.ethemsulan.com/2011/07/get-mac-address-manufacturer-and-model-of-android-device.html</link>
		<comments>http://www.ethemsulan.com/2011/07/get-mac-address-manufacturer-and-model-of-android-device.html#comments</comments>
		<pubDate>Mon, 25 Jul 2011 20:50:31 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1039</guid>
		<description><![CDATA[Bu uygulama ile Android cihazının Mac Adresi, Modeli ve Manufacturer(Üretici) bilgilerini TextView&#8217;e yazmaya çalıştım. Android içinde import android.os.Build; os paketinde bulunan Build static sınıfı ile bir Android cihazlarının birçok bilgilerine erişebiliyoruz. Mesela Build.HARDWARE gibi. Network bilgilerine NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); erişmesi için izin vermemiz lazım. Ayrıca Wifi erişme izni de vermek lazım. &#60;uses-permission android:name=&#34;android.permission.ACCESS_NETWORK_STATE&#34;&#62;&#60;/uses-permission&#62; &#60;uses-permission [...]]]></description>
			<content:encoded><![CDATA[<p>Bu uygulama ile <strong>Android</strong> cihazının <strong>Mac Adresi</strong>, <strong>Model</strong>i ve <strong>Manufacturer</strong>(Üretici) bilgilerini TextView&#8217;e yazmaya çalıştım. Android içinde
<pre class="brush: java;">import android.os.Build; </pre>
<p> os paketinde bulunan <strong>Build static</strong> sınıfı ile bir Android cihazlarının birçok bilgilerine erişebiliyoruz. Mesela <strong>Build.HARDWARE</strong> gibi.<br />
<div id="attachment_1040" class="wp-caption alignnone" style="width: 190px"><a href="http://www.ethemsulan.com/wp-content/uploads/deviceinfo.png"><img src="http://www.ethemsulan.com/wp-content/uploads/deviceinfo-180x300.png" alt="" title="deviceinfo" width="180" height="300" class="size-medium wp-image-1040" /></a><p class="wp-caption-text">Android Device Information</p></div><br />
Network bilgilerine
<pre class="brush: java;">NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);</pre>
<p> erişmesi için izin vermemiz lazım.<br />
Ayrıca Wifi erişme izni de vermek lazım.</p>
<pre class="brush: java;">&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot;&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot;&gt;&lt;/uses-permission&gt;
</pre>
<p>Android telefonumun bilgileri.<br />
<a href="http://www.ethemsulan.com/wp-content/uploads/info1.png"><img src="http://www.ethemsulan.com/wp-content/uploads/info1-180x300.png" alt="" title="info" width="180" height="300" class="alignnone size-medium wp-image-1041" /></a></p>
<p>GetInfoActivity.java</p>
<pre class="brush: java;">
package com.getinfo;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.widget.TextView;

public class GetInfoActivity extends Activity {

	private TextView mac,model,manufacturer;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        model=(TextView) findViewById(R.id.textView1_model);
        mac=(TextView) findViewById(R.id.textView2_mac);
        manufacturer=(TextView) findViewById(R.id.textView3_manufacture);
        model.setText(&quot;Model =&gt; &quot;+ Build.MODEL);

        String mac_adresi=get_mac_address();
		mac.setText(&quot;Mac =&gt; &quot;+mac_adresi);
        manufacturer.setText(&quot;Manufacturer =&gt; &quot;+Build.MANUFACTURER);

    }

    private String get_mac_address()
	{
		ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

	    try{
	    	WifiManager wifiMan = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
	        WifiInfo wifiInf = wifiMan.getConnectionInfo();
	        return wifiInf.getMacAddress();
	    }
	    catch (Exception e) {
	    	return &quot;00:00:00&quot;;
		}
	}
}
</pre>
<p>main.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
    &lt;TextView
    android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot;
    android:layout_height=&quot;wrap_content&quot; android:text=&quot;&quot;
    android:layout_width=&quot;wrap_content&quot;
    android:id=&quot;@+id/textView1_model&quot;&gt;
    &lt;/TextView&gt;
    &lt;TextView
    android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot;
    android:layout_height=&quot;wrap_content&quot; android:text=&quot;&quot;
    android:layout_width=&quot;wrap_content&quot;
    android:id=&quot;@+id/textView2_mac&quot;&gt;
    &lt;/TextView&gt;
    &lt;TextView
    android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot;
    android:layout_height=&quot;wrap_content&quot; android:text=&quot;&quot;
    android:layout_width=&quot;wrap_content&quot;
    android:id=&quot;@+id/textView3_manufacture&quot;&gt;
    &lt;/TextView&gt;
&lt;/LinearLayout&gt;
</pre>
<p>AndroidManifest.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.getinfo&quot;
      android:versionCode=&quot;1&quot;
      android:versionName=&quot;1.0&quot;&gt;

&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot;&gt;&lt;/uses-permission&gt;
&lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot;&gt;&lt;/uses-permission&gt;

    &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt;
        &lt;activity android:name=&quot;.GetInfoActivity&quot;
                  android:label=&quot;@string/app_name&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;/application&gt;
&lt;/manifest&gt;
</pre>
<p><a href="http://hotfile.com/dl/125047512/3dc2c3d/GetInfo.tar.gz.html">Download GetInfo.tar.gz</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/07/get-mac-address-manufacturer-and-model-of-android-device.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make a phone call from your application Android Sample</title>
		<link>http://www.ethemsulan.com/2011/07/how-to-make-a-phone-call-from-your-application-android-sample.html</link>
		<comments>http://www.ethemsulan.com/2011/07/how-to-make-a-phone-call-from-your-application-android-sample.html#comments</comments>
		<pubDate>Sat, 16 Jul 2011 15:36:14 +0000</pubDate>
		<dc:creator>ethemsulan</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.ethemsulan.com/?p=1035</guid>
		<description><![CDATA[Android ile button tiklandiginda yazilan telefon numarasını arıyor. tel:05357139804 tel: dan sonra telefon numaranızı yazıp test edin. AndroidManifest.xml içinde arama izni aşağıdaki gibidir. &#60;uses-permission android:name=&#34;android.permission.CALL_PHONE&#34;&#62;&#60;/uses-permission&#62; PhoneCallActivity.java package com.call.phone; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class PhoneCallActivity extends Activity { private Button button_start_call; @Override public void onCreate(Bundle [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Android</strong> ile <strong>button</strong> tiklandiginda yazilan <strong>telefon numarası</strong>nı arıyor.
<pre class="brush: java;">tel:05357139804</pre>
<p> <strong>tel:</strong> dan sonra telefon numaranızı yazıp test edin.</p>
<p>AndroidManifest.xml içinde arama izni aşağıdaki gibidir.</p>
<pre class="brush: java;">&lt;uses-permission android:name=&quot;android.permission.CALL_PHONE&quot;&gt;&lt;/uses-permission&gt;</pre>
<p>PhoneCallActivity.java</p>
<pre class="brush: java;">
package com.call.phone;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class PhoneCallActivity extends Activity {
    private Button button_start_call;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        button_start_call=(Button) findViewById(R.id.button1);

        button_start_call.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
//Button tiklandiginda bu numara araniyor.
				Intent intent_call=new Intent(Intent.ACTION_CALL, Uri.parse(&quot;tel:05348762815&quot;));
				startActivity(intent_call);
				Toast.makeText(getApplicationContext(), &quot;Wait for call...&quot;, Toast.LENGTH_SHORT).show();
			}
		});
    }
}
</pre>
<p>main.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
    &lt;Button
    android:id=&quot;@+id/button1&quot;
    android:text=&quot;Start Call&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;200dip&quot;&gt;
    &lt;/Button&gt;
&lt;/LinearLayout&gt;
</pre>
<p>AndroidManifest.xml</p>
<pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.call.phone&quot;
      android:versionCode=&quot;1&quot;
      android:versionName=&quot;1.0&quot;&gt;

&lt;uses-permission android:name=&quot;android.permission.CALL_PHONE&quot;&gt;&lt;/uses-permission&gt;

    &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt;
        &lt;activity android:name=&quot;.PhoneCallActivity&quot;
                  android:label=&quot;@string/app_name&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;/application&gt;
&lt;/manifest&gt;
</pre>
<p><a href="http://hotfile.com/dl/125084500/f369acb/PhoneCall.tar.gz.html">Download source code PhoneCall.tar.gz</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ethemsulan.com/2011/07/how-to-make-a-phone-call-from-your-application-android-sample.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

