<?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>Pragun</title>
	<atom:link href="http://pragungoyal.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pragungoyal.com</link>
	<description>is making something</description>
	<lastBuildDate>Wed, 02 Nov 2011 17:39:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pondicherry&#8217;s Shades of Blue</title>
		<link>http://pragungoyal.com/onegallery/pondicherrys-shades-of-blue/</link>
		<comments>http://pragungoyal.com/onegallery/pondicherrys-shades-of-blue/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 17:39:56 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onegallery]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/?p=990</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onegallery/pondicherrys-shades-of-blue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wheel of Creation</title>
		<link>http://pragungoyal.com/onephoto/wheel-of-creation/</link>
		<comments>http://pragungoyal.com/onephoto/wheel-of-creation/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 08:02:58 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onephoto]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/?p=974</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onephoto/wheel-of-creation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Between Bells</title>
		<link>http://pragungoyal.com/onephoto/between-bells/</link>
		<comments>http://pragungoyal.com/onephoto/between-bells/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 07:39:26 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onephoto]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/?p=956</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onephoto/between-bells/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extracting cookies from A WebView, Android</title>
		<link>http://pragungoyal.com/uncategorized/extracting-cookies-from-webview-android/</link>
		<comments>http://pragungoyal.com/uncategorized/extracting-cookies-from-webview-android/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 18:10:21 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/?p=295</guid>
		<description><![CDATA[I was recently writing an application for Android which required pulling out authentication information from WebView. Basically, a user would enter his login credentials (into facebook/twitter ) in WebView and once the user is logged, the cookies need to be stored somewhere such that a HTTP Client could use them.
Cookies used by a WebView can [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently writing an application for Android which required pulling out authentication information from WebView. Basically, a user would enter his login credentials (into facebook/twitter ) in WebView and once the user is logged, the cookies need to be stored somewhere such that a HTTP Client could use them.</p>
<p>Cookies used by a WebView can be accessed/modified by using the CookieManager. CookieManager once instantiated can be used pretty much anywhere but its useful to snatch cookies when pages are finished/started loading. So, I wrote a WebViewClient which uses onPageStarted() and onPageFinished() to execute the cookie extracting procedure. In this example the cookies are saved as SharedPreferences strings, but once you have the cookie in hand ( a string <img src='http://pragungoyal.com/wp/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ) you can do whatever you want to do with it.</p>
<div style="font-size: 1.2em; background-color: #ccc; float: left; clear: both;">
<pre>public void onPageStarted(WebView view, String url, Bitmap favicon)
{
	Log.i( "PageStarted", url );
	String success_url = "http://www.xxxxx.com/login_success";
	String failure_url = "http://www.xxxxx.com/login_failure";
	int fail = url.compareTo(failure_url);
	int success = url.compareTo(success_url);
	if(fail == 0)
	{
		super.onPageStarted(view, url, favicon);
	}
	if(success == 0)
	{
		CookieManager mgr = CookieManager.getInstance();
		Log.i( "URL", url );
		Log.i("Cookie",mgr.getCookie("xxxx.com")+"test");
		String cookie_string = mgr.getCookie("xxxx.com");
		if(cookie_string.length() &gt; 1)
		{
			settings_editor.putBoolean("got_session_cookie",true);
			settings_editor.putString("cookie",cookie_string);
			settings_editor.commit();
		}
		super.onPageStarted(view, url, favicon);
	}
	if((fail != 0)&amp;&amp;(success != 0))
	{
		super.onPageStarted(view, url, favicon);
	}
}
</pre>
</div>
<p style="clear: both;">Now, inserting cookies into an HTTP Client.</p>
<div style="font-size: 1.2em; background-color: #ccc; float: left clear;">
<pre>
DefaultHttpClient httpclient = new DefaultHttpClient();
BasicCookieStore cookieStore = new BasicCookieStore();
String login_cookie_string = settings.getString("cookie", "");
String[] cookie_parts = null;
if(login_cookie_string.length()&gt; 0)
{
	//debug_view.setText(login_cookie_string);
	cookie_parts = login_cookie_string.split("=");
	if(cookie_parts.length == 2)
	{
		for(int t=0;t cookie_parts.length;t++)
		{
			//debug_view.append("part "+cookie_parts[t]);
		}
		Cookie login_cookie = new BasicClientCookie(cookie_parts[0],cookie_parts[1]);
		((BasicClientCookie) login_cookie).setDomain("pragungoyal.com");
		cookieStore.addCookie(login_cookie);
	}
	else
	{
		//debug_view.setText(" couldnt split cookies ");
	}
}
else
{
	//debug_view.setText(" no cookie ");
}

httpclient.setCookieStore(cookieStore);
HttpGet request = new HttpGet("http://www.xxxx.com/");
int status = 0;
boolean got_url = false;
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
try
{
	HttpResponse http_response = httpclient.execute(request);
	if (status != HttpStatus.SC_OK)
	{
		http_response.getEntity().writeTo(ostream);
		debug_view.setText(ostream.toString());
		mainjson = new JSONObject(ostream.toString());
		URLDecoder decode_url = new URLDecoder();
		login_url = URLDecoder.decode(mainjson.getString("login_url"));
		got_url = true;
	}
	else
	{
		InputStream content = http_response.getEntity().getContent();
	}
}
catch (ClientProtocolException e)
{
	debug_view.setText(e.getMessage());
}
catch (IOException e)
{
	debug_view.setText(e.getMessage());
}
catch (JSONException e)
{
	// TODO Auto-generated catch block e.printStackTrace();
	debug_view.setText(e.getMessage());
}
</pre>
</div>
<p style="clear: both;">Here&#8217;s how I do it. Hope It helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/uncategorized/extracting-cookies-from-webview-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Covered in Pink</title>
		<link>http://pragungoyal.com/onephoto/covered-in-pink-2/</link>
		<comments>http://pragungoyal.com/onephoto/covered-in-pink-2/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 07:19:39 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onephoto]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/?p=218</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onephoto/covered-in-pink-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Jeep Driver in Munnar</title>
		<link>http://pragungoyal.com/onephoto/the-jeep-driver-in-munnar/</link>
		<comments>http://pragungoyal.com/onephoto/the-jeep-driver-in-munnar/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 05:24:27 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onephoto]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/onephoto/the-jeep-driver-in-munnar/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onephoto/the-jeep-driver-in-munnar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>People, Passion, Photography</title>
		<link>http://pragungoyal.com/onephoto/people-passion-photography/</link>
		<comments>http://pragungoyal.com/onephoto/people-passion-photography/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 08:34:13 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onephoto]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/uncategorized/people-passion-photography/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onephoto/people-passion-photography/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Rickshaw full of Smiles</title>
		<link>http://pragungoyal.com/onephoto/a-rickshaw-full-of-smiles/</link>
		<comments>http://pragungoyal.com/onephoto/a-rickshaw-full-of-smiles/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 10:47:10 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onephoto]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/?p=204</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onephoto/a-rickshaw-full-of-smiles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Barsana Rooftops</title>
		<link>http://pragungoyal.com/onephoto/barsana-rooftops/</link>
		<comments>http://pragungoyal.com/onephoto/barsana-rooftops/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 21:39:18 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onephoto]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/?p=202</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onephoto/barsana-rooftops/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>One ness</title>
		<link>http://pragungoyal.com/onephoto/one-ness/</link>
		<comments>http://pragungoyal.com/onephoto/one-ness/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 15:38:57 +0000</pubDate>
		<dc:creator>Pragun</dc:creator>
				<category><![CDATA[onephoto]]></category>

		<guid isPermaLink="false">http://pragungoyal.com/onephoto/one-ness/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://pragungoyal.com/onephoto/one-ness/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

