tag:blogger.com,1999:blog-56712269857700175852023-11-15T21:22:15.661+05:30Tarandeep KaurTarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-5671226985770017585.post-58908291335632169842012-10-22T16:23:00.000+05:302012-10-22T16:23:16.206+05:30Hide and Show Button on HeadPhone Attached and Detached<div dir="ltr" style="text-align: left;" trbidi="on">
Broadcast receiver,displays and hide button, when we attach or detach(remove) the headphone.<br />
<br />
Action Used is : <b><i>ACTION_HEADSET_PLUG</i></b><br />
Check state : if state is <b>0</b> means headset/headphone was removed else it is attached.<br />
<br />
<br />
<br />
<div class="p1">
<span class="s1">private</span> <span class="s1">final</span> BroadcastReceiver <span class="s2">headsetReceiver</span> = <span class="s1">new</span> BroadcastReceiver() {</div>
<div class="p2">
<br /></div>
<div class="p3">
<span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>@Override</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s1">public</span> <span class="s1">void</span> onReceive(Context context, Intent intent) {</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>String action = intent.getAction();</div>
<div class="p2">
<br /></div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s1">if</span> ((action.compareTo(Intent.<span class="s2">ACTION_HEADSET_PLUG</span>)) == 0) <span class="s4">// if the</span></div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">// action </span>match a<span class="s4"> </span><span class="s5">headset</span> one</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{</div>
<div class="p2">
<br /></div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s1">int</span> headSetState = intent.getIntExtra(<span class="s6">"state"</span>, 0); <span class="s4">// get the</span></div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">// </span><span class="s5">headset</span> state property<br />
// Log.i("XML", "<span class="s7">Headset</span> Microphone : " + hasMicrophone);</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s1">if</span> (<span class="s2">btn</span> != <span class="s1">null</span>) {</div>
<div class="p4">
<span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s1">if</span><span class="s3"> (headSetState == 0) </span>// <span class="s7">headset</span> was unplugged & has no microphone</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{</div>
<div class="p2">
<span class="s2">btn</span>.setVisibility(View.<span class="s2">INVISIBLE</span>);</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>} <span class="s1">else</span> {</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">btn</span>.setVisibility(View.<span class="s2">VISIBLE</span>);</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</div>
<div class="p2">
<br /></div>
<div class="p1">
<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</div>
<div class="p2">
<br /></div>
<div class="p1">
<span class="Apple-tab-span"> </span>};</div>
</div>
Tarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.com2tag:blogger.com,1999:blog-5671226985770017585.post-42555652954855082712012-08-09T12:24:00.000+05:302012-08-09T12:24:02.701+05:30Retrieve Google Map API Key in Android<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<ul style="border: 0px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1em 30px; padding: 0px; vertical-align: baseline;">
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">Locate the android debug key in your system. it is found on the following locations depending on your operating system (This path will be useful):<ul style="background-color: transparent; border: 0px; list-style: disc; margin: 0px 0px 0px 30px; padding: 0px; vertical-align: baseline;">
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">Windows XP: <code style="background-color: transparent; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;">C:\Documents and Settings\<user>\.android\debug.keystore</code></li>
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">Mac OS X and Linux : <code style="background-color: transparent; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;">~/.android/debug.keystore</code> (where <code style="background-color: transparent; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;">~</code> is the path of your <code style="background-color: transparent; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;">home</code>directory.</li>
</ul>
</li>
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">In a terminal, use the following <code style="background-color: transparent; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;">keytool</code> command to generate the MD5 Hash:<ul style="background-color: transparent; border: 0px; list-style: disc; margin: 0px 0px 0px 30px; padding: 0px; vertical-align: baseline;">
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;"><code style="background-color: transparent; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;">keytool -list -alias androiddebugkey -keystore <path_to_debug_keystore>.keystore -storepass android -keypass android</code></li>
</ul>
</li>
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">Copy the generated hash</li>
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">Go to : <a href="http://code.google.com/android/maps-api-signup.html" rel="nofollow" style="background-color: transparent; border: 0px; color: #4a6b82; cursor: pointer; margin: 0px; padding: 0px; vertical-align: baseline;">code.google. com/android/maps-api-signup.html</a> (you maybe required to login with your Google account)</li>
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">Paste the above generated MD5 hash there, accept the Terms and Conditions and click on<code style="background-color: transparent; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;">Generate</code> button</li>
<li style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;">You'll get the API key for your map. paste this in your XML file</li>
</ul>
</div>Tarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.com0tag:blogger.com,1999:blog-5671226985770017585.post-12888608627843815752012-08-02T12:46:00.000+05:302012-08-02T12:46:34.517+05:30Touch n Share Technology<div dir="ltr" style="text-align: left;" trbidi="on">
<h1>
What is NFC?<o:p></o:p></h1>
<div class="MsoNormal" style="margin-bottom: 12.0pt;">
<span style=" font-family: "Apple Chancery"; font-size: 14.0pt;">Near Field
Communication (NFC) technology makes life easier and more convenient for
consumers around the world by making it simpler to make transactions, exchange
digital content, and connect electronic devices with a touch.<o:p></o:p></span></div>
<h1>
Communication modes<o:p></o:p></h1>
<div class="MsoNormal">
<span style="font-family: "Apple Chancery"; font-size: 14.0pt;">NFC
devices support two communication modes.<o:p></o:p></span></div>
<h2>
Active<o:p></o:p></h2>
<div class="MsoNormal">
<span style="font-family: "Apple Chancery"; font-size: 14.0pt;">In
this mode, the target and the initiator devices have power supplies and can
communicate with one another by alternate signal transmission.<o:p></o:p></span></div>
<h2>
Passive<o:p></o:p></h2>
<div class="MsoNormal">
<span style="font-family: "Apple Chancery"; font-size: 14.0pt;">In
this mode, the initiator device generates radio signals and this
electromagnetic field powers the target device. The target device responds to
the initiator by modulating the existing electromagnetic field.<o:p></o:p></span></div>
<h1>
Operating modes<o:p></o:p></h1>
<div class="MsoNormal">
<span style="font-family: "Apple Chancery"; font-size: 14.0pt;">NFC
devices can operate in three different modes based on the ISO/IEC 18092, NFC
IP-1 and ISO/IEC 14443 contactless smart card standards.<o:p></o:p></span></div>
<h2>
Read/Write<o:p></o:p></h2>
<div class="MsoNormal">
<span style="font-family: "Apple Chancery"; font-size: 14.0pt;">In
this mode, the NFC enabled phone can read or write data to any of the supported
tag types in a standard NFC data format.<o:p></o:p></span></div>
<h2>
Peer to Peer<o:p></o:p></h2>
<div class="MsoNormal">
<span style="font-family: "Apple Chancery"; font-size: 14.0pt;">In
this mode, two NFC-enabled devices can exchange data. For example, you can
share Bluetooth or Wi-Fi link set up parameters to initiate a Bluetooth or
Wi-Fi link. You can also exchange data such as virtual business cards or
digital photos. Peer-to-Peer mode is standardized on the ISO/IEC 18092
standard.<o:p></o:p></span></div>
<h2>
Card emulation<o:p></o:p></h2>
<div class="MsoNormal">
<span style="font-family: "Apple Chancery"; font-size: 14.0pt;">An
NFC-enabled phone acts as reader when in contact with tags. In this mode, the
phone can act as a tag or contactless card for existing readers.<o:p></o:p></span></div>
<h1>
Key Benefits of NFC<o:p></o:p></h1>
<div style="margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;">
<span style=" font-family: "Apple Chancery"; font-size: 14.0pt;">NFC provides a range of benefits to consumers and businesses,
such as:<o:p></o:p></span></div>
<ul type="disc">
<li class="MsoNormal" style=" mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;"><strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">Intuitive</span></strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">:
NFC interactions require no more than a simple touch<o:p></o:p></span></li>
<li class="MsoNormal" style=" mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;"><strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">Versatile</span></strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">:
NFC is ideally suited to the broadest range of industries, environments,
and uses<o:p></o:p></span></li>
<li class="MsoNormal" style=" mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;"><strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">Open and standards-based</span></strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">: The underlying layers of NFC technology follow
universally implemented ISO, ECMA, and ETSI standards<o:p></o:p></span></li>
<li class="MsoNormal" style=" mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;"><strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">Technology-enabling</span></strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">: NFC facilitates fast and simple setup of wireless
technologies, such as Bluetooth, Wi-Fi, etc.)<o:p></o:p></span></li>
<li class="MsoNormal" style=" mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;"><strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">Inherently secure</span></strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">: NFC transmissions are short range (from a touch to a
few centimeters)<o:p></o:p></span></li>
<li class="MsoNormal" style=" mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;"><strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">Interoperable</span></strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">:
NFC works with existing contactless card technologies<o:p></o:p></span></li>
<li class="MsoNormal" style=" mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt;"><strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">Security-ready</span></strong><span style="font-family: "Apple Chancery"; font-size: 14.0pt; mso-fareast-font-family: "Times New Roman";">:
NFC has built-in capabilities to support secure applications</span></li>
</ul>
</div>Tarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.com0tag:blogger.com,1999:blog-5671226985770017585.post-45156987766221714902012-08-01T18:50:00.000+05:302012-08-01T18:50:26.208+05:30MAC KEYBOARD SHORTCUTS<div dir="ltr" style="text-align: left;" trbidi="on">
Windows button is used as Command button<br />
<br />
<table border="1" style:width="100%">
<tr>
<th > Keys </th>
<th > Uses </th>
</tr>
<tr>
<td>
Command +
Option + Esc </td><td> Force quit<br/></td></tr>
<tr>
<td>
Command +
Tab </td><td> cycles through open applications<br /></td></tr>
<tr>
<td>
Command +
F4 </td><td>close document<br /></td></tr>
<tr>
<td>
Command +
Control + F2 </td><td> control the menu bar with the keyboard<br /></td></tr>
<tr>
<td>
Command +
Control + F3 </td><td> control the dock with the keyboard<br /></td></tr>
<tr>
<td>
Command +
Left, right arrows </td><td>Back/forward on web<br /></td></tr>
<tr>
<td>
Command +
A </td><td>select all<br /></td></tr>
<tr>
<td>
Command +
B </td><td>bold font<br /></td></tr>
<tr>
<td>
Command +
C </td><td>copy<br /></td></tr>
<tr>
<td>
Command +
D </td><td>change font<br /></td></tr>
<tr>
<td>
Command +
E </td><td>center alignment<br /></td></tr>
<tr>
<td>
Command +
F </td><td>find<br /></td></tr>
<tr>
<td>
Command +
G </td><td>find next<br /></td></tr>
<tr>
<td>
Command +
H</td><td> replace<br /></td></tr>
<tr>
<td>
Command +
I </td><td>italic font<br /></td></tr>
<tr>
<td>
Command +
J </td><td>justify<br /></td></tr>
<tr>
<td>
Command +
L </td><td>left alignment<br /></td></tr>
<tr>
<td>
Command +
M </td><td>minimize<br /></td></tr>
<tr>
<td>
Command +
N </td><td>new document<br /></td></tr>
<tr>
<td>
Command +
O </td><td>open file<br /></td></tr>
<tr>
<td>
Command +
P </td><td>print<br /></td></tr>
<tr>
<td>
Command +
Q </td><td>quit<br /></td></tr>
<tr>
<td>
Command +
R </td><td>right alignment<br /></td></tr>
<tr>
<td>
Command +
S </td><td>save<br /></td></tr>
<tr>
<td>
Command +
T </td><td>hanging indent<br /></td></tr>
<tr>
<td>
Command +
U </td><td>underline<br /></td></tr>
<tr>
<td>
Command +
V </td><td>paste<br /></td></tr>
<tr>
<td>
Command +
W </td><td>closes file<br /></td></tr>
<tr>
<td>
Command +
X </td><td>cut<br /></td></tr>
<tr>
<td>
Command +
Y </td><td>redo<br /></td></tr>
<tr>
<td>
Command +
Z </td><td>undo<br /></td></tr>
<tr>
<td>
Command +
1 </td><td>single space<br /></td></tr>
<tr>
<td>
Command +
2 </td><td>double space<br /></td></tr>
<tr>
<td>
Command +
5 </td><td>1.5 space<br /></td></tr>
<tr>
<td>
Command +
/ </td><td> Help menu<br /></td></tr>
<tr>
<td>
Command +
Home </td><td>top <br /></td></tr>
<tr>
<td>
Command +
End </td><td>bottom<br /></td></tr>
<tr>
<td>
Command +
F2 </td><td>Print Preview<br /></td></tr>
<tr>
<td>
Command +
Option + L</td><td> Spell check<br /></td></tr>
<tr>
<td>
Command +
Option + R </td><td>Grammar check<br /></td></tr>
<tr>
<td>
Command +
+ Return </td><td>page break<br /></td></tr>
<tr>
<td>
Command + Shift +
Tab </td><td> moves cursor backward<br /></td></tr>
<tr>
<td>
Command + Shift +
Page up </td><td> highlights cursor position to the beginning of the line<br /></td></tr>
<tr>
<td>
Command + Shift +
Page down </td><td>highlights cursor position to the end of the line</td></tr></table></div>Tarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.com1tag:blogger.com,1999:blog-5671226985770017585.post-17475259592955724782012-07-25T10:18:00.001+05:302012-07-25T10:25:01.446+05:30Shortcut Keys for Windows<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
General keyboard shortcuts</h3>
<ul style="color: #FFE6B2 font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+C (Copy)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+X (Cut)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+V (Paste)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+Z (Undo)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">DELETE (Delete)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SHIFT+DELETE (Delete the selected item permanently without placing the item in the Recycle Bin)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL while dragging an item (Copy the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+SHIFT while dragging an item (Create a shortcut to the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F2 key (Rename the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+SHIFT with any of the arrow keys (Highlight a block of text)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SHIFT with any of the arrow keys (Select more than one item in a window or on the desktop, or select text in a document)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+A (Select all)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F3 key (Search for a file or a folder)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+ENTER (View the properties for the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+F4 (Close the active item, or quit the active program)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+ENTER (Display the properties of the selected object)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+SPACEBAR (Open the shortcut menu for the active window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+F4 (Close the active document in programs that enable you to have multiple documents open simultaneously)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+TAB (Switch between the open items)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+ESC (Cycle through items in the order that they had been opened)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F6 key (Cycle through the screen elements in a window or on the desktop)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F4 key (Display the Address bar list in My Computer or Windows Explorer)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SHIFT+F10 (Display the shortcut menu for the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+SPACEBAR (Display the System menu for the active window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+ESC (Display the Start menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+Underlined letter in a menu name (Display the corresponding menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Underlined letter in a command name on an open menu (Perform the corresponding command)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F10 key (Activate the menu bar in the active program)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">RIGHT ARROW (Open the next menu to the right, or open a submenu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">LEFT ARROW (Open the next menu to the left, or close a submenu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F5 key (Update the active window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">BACKSPACE (View the folder one level up in My Computer or Windows Explorer)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ESC (Cancel the current task)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SHIFT when you insert a CD-ROM into the CD-ROM drive (Prevent the CD-ROM from automatically playing)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+SHIFT+ESC (Open Task Manager)</li>
</ul>
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
Dialog box keyboard shortcuts</h3>
<span style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;">If you press SHIFT+F8 in extended selection list boxes, you enable extended selection mode. In this mode, you can use an arrow key to move a cursor without changing the selection. You can press CTRL+SPACEBAR or SHIFT+SPACEBAR to adjust the selection. To cancel extended selection mode, press SHIFT+F8 again. Extended selection mode cancels itself when you move the focus to another control.</span><ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+TAB (Move forward through the tabs)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+SHIFT+TAB (Move backward through the tabs)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">TAB (Move forward through the options)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SHIFT+TAB (Move backward through the options)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+Underlined letter (Perform the corresponding command or select the corresponding option)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ENTER (Perform the command for the active option or button)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SPACEBAR (Select or clear the check box if the active option is a check box)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Arrow keys (Select a button if the active option is a group of option buttons)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F1 key (Display Help)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F4 key (Display the items in the active list)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">BACKSPACE (Open a folder one level up if a folder is selected in the <b>Save As</b> or <b>Open</b> dialog box)</li>
</ul>
<h3 id="tocHeadRef" style="color: #333333; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
Microsoft natural keyboard shortcuts</h3>
<ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo (Display or hide the Start menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+BREAK (Display the <b>System Properties</b> dialog box)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+D (Display the desktop)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+M (Minimize all of the windows)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+SHIFT+M (Restore the minimized windows)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+E (Open My Computer)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+F (Search for a file or a folder)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+Windows Logo+F (Search for computers)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+F1 (Display Windows Help)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+ L (Lock the keyboard)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+R (Open the <b>Run</b> dialog box)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo+U (Open Utility Manager)</li>
</ul>
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
Accessibility keyboard shortcuts</h3>
<ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">Right SHIFT for eight seconds (Switch FilterKeys either on or off)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Left ALT+left SHIFT+PRINT SCREEN (Switch High Contrast either on or off)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Left ALT+left SHIFT+NUM LOCK (Switch the MouseKeys either on or off)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SHIFT five times (Switch the StickyKeys either on or off)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">NUM LOCK for five seconds (Switch the ToggleKeys either on or off)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">Windows Logo +U (Open Utility Manager)</li>
</ul>
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
Windows Explorer keyboard shortcuts</h3>
<ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">END (Display the bottom of the active window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">HOME (Display the top of the active window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">NUM LOCK+Asterisk sign (*) (Display all of the subfolders that are under the selected folder)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">NUM LOCK+Plus sign (+) (Display the contents of the selected folder)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">NUM LOCK+Minus sign (-) (Collapse the selected folder)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">LEFT ARROW (Collapse the current selection if it is expanded, or select the parent folder)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">RIGHT ARROW (Display the current selection if it is collapsed, or select the first subfolder)</li>
</ul>
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
Shortcut keys for Character Map</h3>
<span style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px;">After you double-click a character on the grid of characters, you can move through the grid by using the keyboard shortcuts:</span><ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">RIGHT ARROW (Move to the right or to the beginning of the next line)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">LEFT ARROW (Move to the left or to the end of the previous line)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">UP ARROW (Move up one row)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">DOWN ARROW (Move down one row)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">PAGE UP (Move up one screen at a time)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">PAGE DOWN (Move down one screen at a time)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">HOME (Move to the beginning of the line)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">END (Move to the end of the line)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+HOME (Move to the first character)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+END (Move to the last character)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SPACEBAR (Switch between Enlarged and Normal mode when a character is selected)</li>
</ul>
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
Microsoft Management Console (MMC) main window keyboard shortcuts</h3>
<ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+O (Open a saved console)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+N (Open a new console)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+S (Save the open console)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+M (Add or remove a console item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+W (Open a new window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F5 key (Update the content of all console windows)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+SPACEBAR (Display the MMC window menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+F4 (Close the console)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+A (Display the Action menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+V (Display the View menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+F (Display the File menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+O (Display the Favorites menu)</li>
</ul>
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
MMC console window keyboard shortcuts</h3>
<ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+P (Print the current page or active pane)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+Minus sign (-) (Display the window menu for the active console window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">SHIFT+F10 (Display the Action shortcut menu for the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F1 key (Open the Help topic, if any, for the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F5 key (Update the content of all console windows)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+F10 (Maximize the active console window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+F5 (Restore the active console window)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+ENTER (Display the <b>Properties</b> dialog box, if any, for the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">F2 key (Rename the selected item)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+F4 (Close the active console window. When a console has only one console window, this shortcut closes the console)</li>
</ul>
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
Remote desktop connection navigation</h3>
<ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+ALT+END (Open the Microsoft Windows NT <b>Security</b> dialog box)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+PAGE UP (Switch between programs from left to right)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+PAGE DOWN (Switch between programs from right to left)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+INSERT (Cycle through the programs in most recently used order)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+HOME (Display the Start menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+ALT+BREAK (Switch the client computer between a window and a full screen)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">ALT+DELETE (Display the Windows menu)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+ALT+Minus sign (-) (Place a snapshot of the entire client window area on the Terminal server clipboard and provide the same functionality as pressing ALT+PRINT SCREEN on a local computer.)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+ALT+Plus sign (+) (Place a snapshot of the active window in the client on the Terminal server clipboard and provide the same functionality as pressing PRINT SCREEN on a local computer.)</li>
</ul>
<h3 id="tocHeadRef" style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 20px; font-weight: lighter; margin: 15px 0px; padding: 0px;">
Microsoft Internet Explorer navigation</h3>
<ul style="color: #FFE6B2; font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 13px; margin: 16px 0px 16px 40px; padding: 0px; position: inherit;">
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+B (Open the <b>Organize Favorites</b> dialog box)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+E (Open the Search bar)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+F (Start the Find utility)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+H (Open the History bar)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+I (Open the Favorites bar)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+L (Open the <b>Open</b> dialog box)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+N (Start another instance of the browser with the same Web address)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+O (Open the <b>Open</b> dialog box, the same as CTRL+L)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+P (Open the <b>Print</b> dialog box)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+R (Update the current Web page)</li>
<li style="margin: 0px; padding: 0px; position: inherit;">CTRL+W (Close the current window)</li>
</ul>
</div>Tarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.com0tag:blogger.com,1999:blog-5671226985770017585.post-92177849553727361402012-07-23T14:07:00.002+05:302012-07-23T14:07:22.710+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: -webkit-auto;">
Introduction to Design Patterns</h2>
<h3 style="text-align: -webkit-auto;">
What is a Pattern?</h3>
<div style="text-align: -webkit-auto;">
When experts need to solve a problem, they seldom invent a totally new solution. More often they will recall a similar problem they have solved previously and reuse the essential aspects of the old solution to solve the new problem. They tend to think in problem-solution pairs.</div>
<div style="text-align: -webkit-auto;">
Identifying the essential aspects of specific problem-solution pairs leads to descriptions of problem-solving <strong><em>patterns</em></strong> that can be reused.</div>
<div style="text-align: -webkit-auto;">
The concept of a pattern as used in software architecture is borrowed from the field of (building) architecture, in particular from the writings of architect Christopher Alexander.</div>
<dl style="text-align: -webkit-auto;">
<dt>Definition:</dt>
<dd>"A <strong><em>pattern for software architecture</em></strong> describes a particular recurring design problem that arises in specific design contexts and presents a well-proven generic scheme for its solution. The solution scheme is specified by describing its constituent components, their responsibilities and relationships, and the ways in which they collaborate." [Buschmann].</dd></dl>
<div style="text-align: -webkit-auto;">
Where software architecture is concerned, the concept of a pattern described here is essentially the same concept as an <strong><em>architectural style</em></strong> or <strong><em>architectural idiom</em></strong> in the Shaw and Garlan book.</div>
<div style="text-align: -webkit-auto;">
In general, patterns have the following characteristics [Buschmann]:</div>
<ul style="text-align: -webkit-auto;">
<li>A pattern describes a solution to a recurring problem that arises in specific design situations.</li>
<li>Patterns are not invented; they are distilled from practical experience.</li>
<li>Patterns describe a group of components (e.g., classes or objects), how the components interact, and the responsibilities of each component. That is, they are higher level abstractions than classes or objects.</li>
<li>Patterns provide a vocabulary for communication among designers. The choice of a name for a pattern is very important.</li>
<li>Patterns help document the architectural vision of a design. If the vision is clearly understood, it will less likely be violated when the system is modified.</li>
<li>Patterns provide a conceptual skeleton for a solution to a design problem and, hence, encourage the construction of software with well-defined properties</li>
<li>Patterns are building blocks for the construction of more complex designs.</li>
<li>Patterns help designers manage the complexity of the software. When a recurring pattern is identified, the corresponding general solution can be implemented productively to provide a reliable software system.</li>
</ul>
<h3 style="text-align: -webkit-auto;">
Descriptions of Patterns</h3>
<div style="text-align: -webkit-auto;">
Various authors use different formats (i.e., "languages") for describing patterns. Typically a pattern will be described with a schema that includes at least the following three parts [Buschmann]:</div>
<ol style="text-align: -webkit-auto;">
<li>Context</li>
<li>Problem</li>
<li>Solution</li>
</ol>
<h4 style="text-align: -webkit-auto;">
Context</h4>
<div style="text-align: -webkit-auto;">
The Context section describes the situation in which the design problem arises.</div>
<h4 style="text-align: -webkit-auto;">
Problem</h4>
<div style="text-align: -webkit-auto;">
The Problem section describes the problem that arises repeatedly in the context.</div>
<div style="text-align: -webkit-auto;">
In particular, the description describes the set of <strong><em>forces</em></strong> repeatedly arising in the context. A force is some aspect of the problem that must be considered when attempting a solution. Example types of forces include:</div>
<ul style="text-align: -webkit-auto;">
<li>requirements the solution must satisfy (e.g., efficiency)</li>
<li>constraints that must be considered (e.g., use of a certain algorithm or protocol)</li>
<li>desirable properties of a solution (e.g., easy to modify)</li>
</ul>
<div style="text-align: -webkit-auto;">
Forces may complementary (i.e., can be achieved simultaneously) or contradictory (i.e., can only be balanced).</div>
<h4 style="text-align: -webkit-auto;">
Solution</h4>
<div style="text-align: -webkit-auto;">
The Solution section describes a proven solution to the problem.</div>
<div style="text-align: -webkit-auto;">
The solution specifies a configuration of elements to balance the forces associated with the problem.</div>
<ul style="text-align: -webkit-auto;">
<li>A pattern describes the static structure of the configuration, identifying the components and the connectors (i.e., the relationships among the components).</li>
<li>A pattern also describes the dynamic runtime behavior of the configuration, identifying the control structure of the components and connectors.</li>
</ul>
<br /></div>Tarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.com0tag:blogger.com,1999:blog-5671226985770017585.post-27357035174994785832012-07-11T17:35:00.001+05:302012-07-11T17:35:29.528+05:30Tarandeep Kaur: Facebook Integration with Android App - PostToWall...<a href="http://tarandeepkaurz.blogspot.com/2012/07/facebook-integration-with-android-app.html?spref=bl">Tarandeep Kaur: Facebook Integration with Android App - PostToWall...</a>: Steps to Integrate Facebook in Android Application: 1. download facebook library from https://github.com/facebook/facebook-android-sdk/ ...Tarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.com0tag:blogger.com,1999:blog-5671226985770017585.post-7608544109933026002012-07-11T17:28:00.001+05:302012-07-11T17:28:06.444+05:30Facebook Integration with Android App - PostToWall Dynamic message<div dir="ltr" style="text-align: left;" trbidi="on">
Steps to Integrate Facebook in Android Application:<br />
1. download facebook library from <a href="https://github.com/facebook/facebook-android-sdk/">https://github.com/facebook/facebook-android-sdk/</a><br />
2. create a new android project with existing source code and give the path of above downloaded "facebook" folder only.<br />
3. create new project.<br />
4. First Activity:<br />
<br />
<br />
<br />
package com.taran.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Intent;<br />
import android.os.Bundle;<br />
import android.util.Log;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
<br />
public class PostMsgActivity extends Activity {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Button btnShow;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>EditText etText;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>protected void onCreate(Bundle savedInstanceState) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>super.onCreate(savedInstanceState);<br />
Log.v("t","ONCreate....");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>setContentView(R.layout.main);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>protected void onStart() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>super.onStart();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Log.v("t","onStart....");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>btnShow = (Button)findViewById(R.id.btnShow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>etText = (EditText)findViewById(R.id.etText);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>btnShow.setOnClickListener(new OnClickListener() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void onClick(View v) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// TODO Auto-generated method stub<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>String str = etText.getText().toString();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Intent intent = new Intent(PostMsgActivity.this,FBAppActivity.class);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>intent.putExtra("facebookMessage", str);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>startActivity(intent);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>});<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
}<br />
<br />
Main.xml<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="250dp"<br />
android:layout_height="125dp" ><br />
<br />
<Button<br />
android:id="@+id/btnShow"<br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"<br />
android:layout_alignParentLeft="true"<br />
android:text="SHOW" /><br />
<br />
<EditText<br />
android:id="@+id/etText"<br />
android:layout_width="match_parent"<br />
android:layout_height="wrap_content"<br />
android:layout_alignParentBottom="true"<br />
android:layout_alignParentLeft="true"<br />
android:ems="10" /><br />
<br />
</RelativeLayout><br />
<br />
<br />
Second Activity:<br />
<br />
package com.taran.android;<br />
<br />
import android.app.Activity;<br />
import android.content.Context;<br />
import android.content.SharedPreferences;<br />
import android.content.SharedPreferences.Editor;<br />
import android.os.Bundle;<br />
import android.util.Log;<br />
import android.view.View;<br />
import android.view.Window;<br />
import android.widget.Toast;<br />
<br />
import com.facebook.android.DialogError;<br />
import com.facebook.android.Facebook;<br />
import com.facebook.android.Facebook.DialogListener;<br />
import com.facebook.android.FacebookError;<br />
<br />
public class FBAppActivity extends Activity {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static final String APP_ID = "434327979941439";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static final String[] PERMISSIONS = new String[]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{ "publish_stream" };<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static final String TOKEN = "access_token";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static final String EXPIRES = "expires_in";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static final String KEY = "facebook-credentials";<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private Facebook facebook;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private String messageToPost;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public boolean saveCredentials(Facebook facebook) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Editor editor = getApplicationContext().getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>editor.putString(TOKEN, facebook.getAccessToken());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>editor.putLong(EXPIRES, facebook.getAccessExpires());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return editor.commit();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public boolean restoreCredentials(Facebook facebook) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(KEY, Context.MODE_PRIVATE);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>facebook.setAccessToken(sharedPreferences.getString(TOKEN, null));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>facebook.setAccessExpires(sharedPreferences.getLong(EXPIRES, 0));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return facebook.isSessionValid();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>protected void onCreate(Bundle savedInstanceState) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>super.onCreate(savedInstanceState);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>facebook = new Facebook(APP_ID);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>restoreCredentials(facebook);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>requestWindowFeature(Window.FEATURE_NO_TITLE);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>setContentView(R.layout.facebook_sample);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>String facebookMessage = getIntent().getStringExtra("facebookMessage");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (facebookMessage == null) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>facebookMessage = "Test wall post";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>messageToPost = facebookMessage;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void doNotShare(View button) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void share(View button) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!facebook.isSessionValid()) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>loginAndPostToWall();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>postToWall(messageToPost);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void loginAndPostToWall() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void postToWall(String message) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Bundle parameters = new Bundle();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>parameters.putString("message", message);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>parameters.putString("description", "topic share");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>try {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>facebook.request("me");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>String response = facebook.request("me/feed", parameters, "POST");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Log.d("Tests", "got response: " + response);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (response == null || response.equals("") || response.equals("false")) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>showToast("Blank response.");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>showToast("Message posted to your facebook wall!");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} catch (Exception e) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>showToast("Failed to post to wall!");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>e.printStackTrace();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>class LoginDialogListener implements DialogListener {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void onComplete(Bundle values) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>saveCredentials(facebook);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (messageToPost != null) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>postToWall(messageToPost);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void onFacebookError(FacebookError error) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>showToast("Authentication with Facebook failed!");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void onError(DialogError error) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>showToast("Authentication with Facebook failed!");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void onCancel() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>showToast("Authentication with Facebook cancelled!");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>finish();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private void showToast(String message) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<br />
}<br />
<br />
<br />
Facebook_sample.xml<br />
<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="250dp"<br />
android:layout_height="125dp" ><br />
<br />
<LinearLayout<br />
android:layout_width="fill_parent"<br />
android:layout_height="wrap_content"<br />
android:layout_alignParentTop="true"<br />
android:layout_gravity="center"<br />
android:orientation="vertical"<br />
android:padding="5dp" ><br />
<br />
<TextView<br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"<br />
android:layout_gravity="center_horizontal"<br />
android:padding="5dp"<br />
android:text="Do you want to share this on Facebook?" /><br />
</LinearLayout><br />
<br />
<LinearLayout<br />
android:layout_width="fill_parent"<br />
android:layout_height="wrap_content"<br />
android:layout_alignParentBottom="true"<br />
android:layout_gravity="center"<br />
android:orientation="horizontal" ><br />
<br />
<Button<br />
android:id="@+id/FacebookShareButton"<br />
android:layout_width="120dp"<br />
android:layout_height="wrap_content"<br />
android:layout_alignParentBottom="true"<br />
android:layout_centerHorizontal="true"<br />
android:layout_gravity="center_horizontal"<br />
android:layout_margin="2dp"<br />
android:onClick="share"<br />
android:padding="5dp"<br />
android:text="Yes" /><br />
<br />
<Button<br />
android:id="@+id/FacebookShareNotButton"<br />
android:layout_width="120dp"<br />
android:layout_height="wrap_content"<br />
android:layout_alignParentBottom="true"<br />
android:layout_centerHorizontal="true"<br />
android:layout_gravity="center_horizontal"<br />
android:layout_margin="2dp"<br />
android:onClick="doNotShare"<br />
android:padding="5dp"<br />
android:text="No" /><br />
</LinearLayout><br />
<br />
</RelativeLayout><br />
<br />
AndroidManifest file:<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"<br />
package="com.taran.android"<br />
android:versionCode="1"<br />
android:versionName="1.0" ><br />
<br />
<uses-sdk android:minSdkVersion="8" /><br />
<br />
<uses-permission android:name="android.permission.INTERNET" /><br />
<br />
<application<br />
android:icon="@drawable/ic_launcher"<br />
android:label="@string/app_name" ><br />
<activity<br />
android:name=".PostMsgActivity"<br />
android:label="@string/app_name" ><br />
<intent-filter><br />
<action android:name="android.intent.action.MAIN" /><br />
<br />
<category android:name="android.intent.category.LAUNCHER" /><br />
</intent-filter><br />
</activity><br />
<activity<br />
android:name=".FBAppActivity"<br />
android:screenOrientation="portrait"<br />
android:theme="@android:style/Theme.Dialog" ><br />
</activity><br />
</application><br />
<br />
</manifest><br />
<br />
Any Confusions,Feel free to ask.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div>
<br /></div>
</div>Tarandeepkaurhttp://www.blogger.com/profile/01751843891408885979noreply@blogger.com31