Monday, October 22, 2012

Hide and Show Button on HeadPhone Attached and Detached

Broadcast receiver,displays and hide button, when we attach or detach(remove) the headphone.

Check state : if state is 0 means headset/headphone was removed else it is attached.

private final BroadcastReceiver headsetReceiver = new BroadcastReceiver() {

public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

if ((action.compareTo(Intent.ACTION_HEADSET_PLUG)) == 0) // if the
// action match a headset one

int headSetState = intent.getIntExtra("state", 0); // get the
// headset state property
// Log.i("XML", "Headset Microphone : " + hasMicrophone);
if (btn != null) {
if (headSetState == 0) // headset was unplugged & has no microphone
} else {



Thursday, August 9, 2012

Retrieve Google Map API Key in Android

  • 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):
    • Windows XP: C:\Documents and Settings\<user>\.android\debug.keystore
    • Mac OS X and Linux : ~/.android/debug.keystore (where ~ is the path of your homedirectory.
  • In a terminal, use the following keytool command to generate the MD5 Hash:
    • keytool -list -alias androiddebugkey -keystore <path_to_debug_keystore>.keystore -storepass android -keypass android
  • Copy the generated hash
  • Go to : com/android/maps-api-signup.html (you maybe required to login with your Google account)
  • Paste the above generated MD5 hash there, accept the Terms and Conditions and click onGenerate button
  • You'll get the API key for your map. paste this in your XML file

Thursday, August 2, 2012

Touch n Share Technology

What is NFC?

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.

Communication modes

NFC devices support two communication modes.


In this mode, the target and the initiator devices have power supplies and can communicate with one another by alternate signal transmission.


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.

Operating modes

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.


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.

Peer to Peer

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.

Card emulation

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.

Key Benefits of NFC

NFC provides a range of benefits to consumers and businesses, such as:
  • Intuitive: NFC interactions require no more than a simple touch
  • Versatile: NFC is ideally suited to the broadest range of industries, environments, and uses
  • Open and standards-based: The underlying layers of NFC technology follow universally implemented ISO, ECMA, and ETSI standards
  • Technology-enabling: NFC facilitates fast and simple setup of wireless technologies, such as Bluetooth, Wi-Fi, etc.)
  • Inherently secure: NFC transmissions are short range (from a touch to a few centimeters)
  • Interoperable: NFC works with existing contactless card technologies
  • Security-ready: NFC has built-in capabilities to support secure applications

Wednesday, August 1, 2012


Windows button is used as Command button

Keys Uses
Command + Option + Esc Force quit
Command + Tab cycles through open applications
Command + F4 close document
Command + Control + F2 control the menu bar with the keyboard
Command + Control + F3 control the dock with the keyboard
Command + Left, right arrows Back/forward on web
Command + A select all
Command + B bold font
Command + C copy
Command + D change font
Command + E center alignment
Command + F find
Command + G find next
Command + H replace
Command + I italic font
Command + J justify
Command + L left alignment
Command + M minimize
Command + N new document
Command + O open file
Command + P print
Command + Q quit
Command + R right alignment
Command + S save
Command + T hanging indent
Command + U underline
Command + V paste
Command + W closes file
Command + X cut
Command + Y redo
Command + Z undo
Command + 1 single space
Command + 2 double space
Command + 5 1.5 space
Command + / Help menu
Command + Home top
Command + End bottom
Command + F2 Print Preview
Command + Option + L Spell check
Command + Option + R Grammar check
Command +  + Return page break
Command + Shift + Tab moves cursor backward
Command + Shift + Page up highlights cursor position to the beginning of the line
Command + Shift + Page down highlights cursor position to the end of the line

Wednesday, July 25, 2012

Shortcut Keys for Windows

General keyboard shortcuts

  • CTRL+C (Copy)
  • CTRL+X (Cut)
  • CTRL+V (Paste)
  • CTRL+Z (Undo)
  • DELETE (Delete)
  • SHIFT+DELETE (Delete the selected item permanently without placing the item in the Recycle Bin)
  • CTRL while dragging an item (Copy the selected item)
  • CTRL+SHIFT while dragging an item (Create a shortcut to the selected item)
  • F2 key (Rename the selected item)
  • CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word)
  • CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word)
  • CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph)
  • CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph)
  • CTRL+SHIFT with any of the arrow keys (Highlight a block of text)
  • 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)
  • CTRL+A (Select all)
  • F3 key (Search for a file or a folder)
  • ALT+ENTER (View the properties for the selected item)
  • ALT+F4 (Close the active item, or quit the active program)
  • ALT+ENTER (Display the properties of the selected object)
  • ALT+SPACEBAR (Open the shortcut menu for the active window)
  • CTRL+F4 (Close the active document in programs that enable you to have multiple documents open simultaneously)
  • ALT+TAB (Switch between the open items)
  • ALT+ESC (Cycle through items in the order that they had been opened)
  • F6 key (Cycle through the screen elements in a window or on the desktop)
  • F4 key (Display the Address bar list in My Computer or Windows Explorer)
  • SHIFT+F10 (Display the shortcut menu for the selected item)
  • ALT+SPACEBAR (Display the System menu for the active window)
  • CTRL+ESC (Display the Start menu)
  • ALT+Underlined letter in a menu name (Display the corresponding menu)
  • Underlined letter in a command name on an open menu (Perform the corresponding command)
  • F10 key (Activate the menu bar in the active program)
  • RIGHT ARROW (Open the next menu to the right, or open a submenu)
  • LEFT ARROW (Open the next menu to the left, or close a submenu)
  • F5 key (Update the active window)
  • BACKSPACE (View the folder one level up in My Computer or Windows Explorer)
  • ESC (Cancel the current task)
  • SHIFT when you insert a CD-ROM into the CD-ROM drive (Prevent the CD-ROM from automatically playing)
  • CTRL+SHIFT+ESC (Open Task Manager)

Dialog box keyboard shortcuts

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.
  • CTRL+TAB (Move forward through the tabs)
  • CTRL+SHIFT+TAB (Move backward through the tabs)
  • TAB (Move forward through the options)
  • SHIFT+TAB (Move backward through the options)
  • ALT+Underlined letter (Perform the corresponding command or select the corresponding option)
  • ENTER (Perform the command for the active option or button)
  • SPACEBAR (Select or clear the check box if the active option is a check box)
  • Arrow keys (Select a button if the active option is a group of option buttons)
  • F1 key (Display Help)
  • F4 key (Display the items in the active list)
  • BACKSPACE (Open a folder one level up if a folder is selected in the Save As or Open dialog box)

Microsoft natural keyboard shortcuts

  • Windows Logo (Display or hide the Start menu)
  • Windows Logo+BREAK (Display the System Properties dialog box)
  • Windows Logo+D (Display the desktop)
  • Windows Logo+M (Minimize all of the windows)
  • Windows Logo+SHIFT+M (Restore the minimized windows)
  • Windows Logo+E (Open My Computer)
  • Windows Logo+F (Search for a file or a folder)
  • CTRL+Windows Logo+F (Search for computers)
  • Windows Logo+F1 (Display Windows Help)
  • Windows Logo+ L (Lock the keyboard)
  • Windows Logo+R (Open the Run dialog box)
  • Windows Logo+U (Open Utility Manager)

Accessibility keyboard shortcuts

  • Right SHIFT for eight seconds (Switch FilterKeys either on or off)
  • Left ALT+left SHIFT+PRINT SCREEN (Switch High Contrast either on or off)
  • Left ALT+left SHIFT+NUM LOCK (Switch the MouseKeys either on or off)
  • SHIFT five times (Switch the StickyKeys either on or off)
  • NUM LOCK for five seconds (Switch the ToggleKeys either on or off)
  • Windows Logo +U (Open Utility Manager)

Windows Explorer keyboard shortcuts

  • END (Display the bottom of the active window)
  • HOME (Display the top of the active window)
  • NUM LOCK+Asterisk sign (*) (Display all of the subfolders that are under the selected folder)
  • NUM LOCK+Plus sign (+) (Display the contents of the selected folder)
  • NUM LOCK+Minus sign (-) (Collapse the selected folder)
  • LEFT ARROW (Collapse the current selection if it is expanded, or select the parent folder)
  • RIGHT ARROW (Display the current selection if it is collapsed, or select the first subfolder)

Shortcut keys for Character Map

After you double-click a character on the grid of characters, you can move through the grid by using the keyboard shortcuts:
  • RIGHT ARROW (Move to the right or to the beginning of the next line)
  • LEFT ARROW (Move to the left or to the end of the previous line)
  • UP ARROW (Move up one row)
  • DOWN ARROW (Move down one row)
  • PAGE UP (Move up one screen at a time)
  • PAGE DOWN (Move down one screen at a time)
  • HOME (Move to the beginning of the line)
  • END (Move to the end of the line)
  • CTRL+HOME (Move to the first character)
  • CTRL+END (Move to the last character)
  • SPACEBAR (Switch between Enlarged and Normal mode when a character is selected)

Microsoft Management Console (MMC) main window keyboard shortcuts

  • CTRL+O (Open a saved console)
  • CTRL+N (Open a new console)
  • CTRL+S (Save the open console)
  • CTRL+M (Add or remove a console item)
  • CTRL+W (Open a new window)
  • F5 key (Update the content of all console windows)
  • ALT+SPACEBAR (Display the MMC window menu)
  • ALT+F4 (Close the console)
  • ALT+A (Display the Action menu)
  • ALT+V (Display the View menu)
  • ALT+F (Display the File menu)
  • ALT+O (Display the Favorites menu)

MMC console window keyboard shortcuts

  • CTRL+P (Print the current page or active pane)
  • ALT+Minus sign (-) (Display the window menu for the active console window)
  • SHIFT+F10 (Display the Action shortcut menu for the selected item)
  • F1 key (Open the Help topic, if any, for the selected item)
  • F5 key (Update the content of all console windows)
  • CTRL+F10 (Maximize the active console window)
  • CTRL+F5 (Restore the active console window)
  • ALT+ENTER (Display the Properties dialog box, if any, for the selected item)
  • F2 key (Rename the selected item)
  • CTRL+F4 (Close the active console window. When a console has only one console window, this shortcut closes the console)

Remote desktop connection navigation

  • CTRL+ALT+END (Open the Microsoft Windows NT Security dialog box)
  • ALT+PAGE UP (Switch between programs from left to right)
  • ALT+PAGE DOWN (Switch between programs from right to left)
  • ALT+INSERT (Cycle through the programs in most recently used order)
  • ALT+HOME (Display the Start menu)
  • CTRL+ALT+BREAK (Switch the client computer between a window and a full screen)
  • ALT+DELETE (Display the Windows menu)
  • 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.)
  • 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.)

Microsoft Internet Explorer navigation

  • CTRL+B (Open the Organize Favorites dialog box)
  • CTRL+E (Open the Search bar)
  • CTRL+F (Start the Find utility)
  • CTRL+H (Open the History bar)
  • CTRL+I (Open the Favorites bar)
  • CTRL+L (Open the Open dialog box)
  • CTRL+N (Start another instance of the browser with the same Web address)
  • CTRL+O (Open the Open dialog box, the same as CTRL+L)
  • CTRL+P (Open the Print dialog box)
  • CTRL+R (Update the current Web page)
  • CTRL+W (Close the current window)

Monday, July 23, 2012

Introduction to Design Patterns

What is a Pattern?

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.
Identifying the essential aspects of specific problem-solution pairs leads to descriptions of problem-solving patterns that can be reused.
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.
"A pattern for software architecture 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].
Where software architecture is concerned, the concept of a pattern described here is essentially the same concept as an architectural style or architectural idiom in the Shaw and Garlan book.
In general, patterns have the following characteristics [Buschmann]:
  • A pattern describes a solution to a recurring problem that arises in specific design situations.
  • Patterns are not invented; they are distilled from practical experience.
  • 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.
  • Patterns provide a vocabulary for communication among designers. The choice of a name for a pattern is very important.
  • 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.
  • Patterns provide a conceptual skeleton for a solution to a design problem and, hence, encourage the construction of software with well-defined properties
  • Patterns are building blocks for the construction of more complex designs.
  • 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.

Descriptions of Patterns

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]:
  1. Context
  2. Problem
  3. Solution


The Context section describes the situation in which the design problem arises.


The Problem section describes the problem that arises repeatedly in the context.
In particular, the description describes the set of forces 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:
  • requirements the solution must satisfy (e.g., efficiency)
  • constraints that must be considered (e.g., use of a certain algorithm or protocol)
  • desirable properties of a solution (e.g., easy to modify)
Forces may complementary (i.e., can be achieved simultaneously) or contradictory (i.e., can only be balanced).


The Solution section describes a proven solution to the problem.
The solution specifies a configuration of elements to balance the forces associated with the problem.
  • A pattern describes the static structure of the configuration, identifying the components and the connectors (i.e., the relationships among the components).
  • A pattern also describes the dynamic runtime behavior of the configuration, identifying the control structure of the components and connectors.

Wednesday, July 11, 2012

Tarandeep Kaur: Facebook Integration with Android App - PostToWall...

Tarandeep Kaur: Facebook Integration with Android App - PostToWall...: Steps to Integrate Facebook in Android Application: 1. download facebook library from ...

Facebook Integration with Android App - PostToWall Dynamic message

Steps to Integrate Facebook in Android Application:
1. download facebook library from
2. create a new android project with existing source code and give the path of above downloaded "facebook" folder only.
3. create new project.
4. First Activity:


import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class PostMsgActivity extends Activity {
Button btnShow;
EditText etText;

protected void onCreate(Bundle savedInstanceState) {
protected void onStart() {
btnShow = (Button)findViewById(;
etText = (EditText)findViewById(;

btnShow.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
String str = etText.getText().toString();
Intent intent = new Intent(PostMsgActivity.this,FBAppActivity.class);
intent.putExtra("facebookMessage", str);





<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
    android:layout_height="125dp" >

        android:text="SHOW" />

        android:ems="10" />


Second Activity:


import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Toast;


public class FBAppActivity extends Activity {
private static final String APP_ID = "434327979941439";
private static final String[] PERMISSIONS = new String[]
{ "publish_stream" };

private static final String TOKEN = "access_token";
private static final String EXPIRES = "expires_in";
private static final String KEY = "facebook-credentials";

private Facebook facebook;
private String messageToPost;

public boolean saveCredentials(Facebook facebook) {
Editor editor = getApplicationContext().getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
editor.putString(TOKEN, facebook.getAccessToken());
editor.putLong(EXPIRES, facebook.getAccessExpires());
return editor.commit();

public boolean restoreCredentials(Facebook facebook) {
SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(KEY, Context.MODE_PRIVATE);
facebook.setAccessToken(sharedPreferences.getString(TOKEN, null));
facebook.setAccessExpires(sharedPreferences.getLong(EXPIRES, 0));
return facebook.isSessionValid();

protected void onCreate(Bundle savedInstanceState) {

facebook = new Facebook(APP_ID);



String facebookMessage = getIntent().getStringExtra("facebookMessage");
if (facebookMessage == null) {
facebookMessage = "Test wall post";
messageToPost = facebookMessage;

public void doNotShare(View button) {

public void share(View button) {
if (!facebook.isSessionValid()) {
} else {

public void loginAndPostToWall() {
facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());

public void postToWall(String message) {
Bundle parameters = new Bundle();
parameters.putString("message", message);
parameters.putString("description", "topic share");
try {
String response = facebook.request("me/feed", parameters, "POST");
Log.d("Tests", "got response: " + response);
if (response == null || response.equals("") || response.equals("false")) {
showToast("Blank response.");
} else {
showToast("Message posted to your facebook wall!");
} catch (Exception e) {
showToast("Failed to post to wall!");

class LoginDialogListener implements DialogListener {
public void onComplete(Bundle values) {
if (messageToPost != null) {

public void onFacebookError(FacebookError error) {
showToast("Authentication with Facebook failed!");

public void onError(DialogError error) {
showToast("Authentication with Facebook failed!");

public void onCancel() {
showToast("Authentication with Facebook cancelled!");

private void showToast(String message) {
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
    android:layout_height="125dp" >

        android:padding="5dp" >

            android:text="Do you want to share this on Facebook?" />

        android:orientation="horizontal" >

            android:text="Yes" />

            android:text="No" />


AndroidManifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <uses-permission android:name="android.permission.INTERNET" />

        android:label="@string/app_name" >
            android:label="@string/app_name" >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            android:theme="@android:style/Theme.Dialog" >


Any Confusions,Feel free to ask.