Choose Your Language

Thursday 12 September 2013

Generate QRCode using java

import java.io.*;
import java.util.Date;
import net.glxn.qrgen.image.ImageType;

public class QRCode {
    public static void main(String[] args) {
        ByteArrayOutputStream out = net.glxn.qrgen.QRCode.from("Aravind Sankaran").to(ImageType.PNG).stream();
 Date d=new Date();
 String filename="c:\\"+d.getTime()+".png";
        try {           
            FileOutputStream fout = new FileOutputStream(new File(filename));
            fout.write(out.toByteArray());
            fout.flush();
            fout.close();
        } catch (FileNotFoundException e) {
                       e.printStackTrace();
        } catch (IOException e) {
                       e.printStackTrace();
        }
    }
}

jar file:
qrgen-1.0.jar
zxing-core-1.7.jar
zxing-j2se-1.7.jar


How to add two numbers without using "+" symbol

public class AdditionWithoutPlusSymbol{
    public static void  main(String args[]){
        int a,b,c;
        a=10;b=20;
        c=(a-(-b));
        System.out.print("Addition Result is "+c);
    }
}

output:
Addition Result is 30

Wednesday 4 September 2013

How to install Android


System Requirements

1. Supported Operating Systems

*          Windows XP (32-bit) or Vista (32- or 64-bit)

*          Mac OS X 10.4.8 or later (x86 only)

*          Linux (tested on Linux Ubuntu Hardy Heron)

           
2. Supported Development Environments

*          Eclipse 3.4 (Ganymede) or 3.5 (Galileo)
           
*          JDK 5 or JDK 6 (JRE alone is not sufficient)

*          Android Development Tools plugin (optional)

*          Not compatible with Gnu Compiler for Java (gcj)
 

3.Other Development Environments or IDEs

*          JDK 5 or JDK 6 (JRE alone is not sufficient)

*          Apache Ant 1.6.5 or later for Linux and Mac, 1.7 or later for Windows

*          Not compatible with Gnu Compiler for Java (gcj)


Install android_sdk_windows_1.6

After downloading the Android SDK, unpack the Android SDK.zip archive to a suitable location on your machine. By default, the SDK files are unpacked into a directory named android_sdk_ <platform>_<release>. Here we are going to install android-sdk-windows-1.6_r1.

Make a note of the name and location of the unpacked SDK directory on your system — you will need to refer to the SDK directory later, when setting up the Android plugin or when using the SDK tools.

Optionally, you may want to add the location of the SDK's primary tools directory to your system PATH. The primary tools/ directory is located at the root of the SDK folder. Adding tools to your path lets you run Android Debug Bridge (adb) and the other command line tools without needing to supply the full path to the tools directory.

On Windows,

1. Right-click on My Computer, and select Properties.

2. Under the Advanced tab, hit the Environment Variables button, and in the dialog that comes up,

3. Double-click on Path (under System Variables).

4. Add the full path to the tools/ directory to the path.

Example:
Set variable name as path &
variable value as,like D:\android-sdk-1.6_r1\tools

On Linux,

1. Edit your ~/.bash_profile or ~/.bashrc file.

2. Look for a line that sets the PATH environment variable and

3. Add the full path to the tools/ directory to it. If you don't see a line setting the path, you can add one:
export PATH=${PATH}:<your_sdk_dir>/tools

On a Mac,

Look in your home directory for .bash_profile and proceed as for Linux. You can create the .bash_profile if you haven't already set one up on your machine.

Note that, if you update your SDK in the future, you should remember to update your PATH settings to point to the new location, if different.

If you will be using the Eclipse IDE as your development environment, the next section describes how to install the Android Development Tools (ADT) plugin and set up Eclipse. If you choose not to use Eclipse, you can develop Android applications in an IDE of your choice and then compile, debug and deploy using the tools included in the SDK (skip to Next Steps).


Install the ADT Plugin for Eclipse

Android offers a custom plugin for the Eclipse IDE, called Android Development Tools (ADT), that is designed to give you a powerful, integrated environment in which to build Android applications. It extends the capabilites of Eclipse to let you quickly set up new Android projects, create an application UI, add components based on the Android Framework API, debug your applications using the Android SDK tools, and even export signed (or unsigned) APKs in order to distribute your application.
In general, using Eclipse with ADT is a highly recommended approach to Android development and is the fastest way to get started. (If you prefer to work in an IDE other than Eclipse, you do not need to install Eclipse or ADT, instead, you can directly use the SDK tools to build and debug your application—skip to Next Steps.)

Once you have the Eclipse IDE installed, as described in Preparing for Installation, follow the steps below to download the ADT plugin and install it in your respective Eclipse environment.


Eclipse 3.4 (Ganymede)

1. Start Eclipse, then select Help > Software Updates.... In the dialog that appears, click the Available Software tab.

2. Click Add Site...

3. In the Add Site dialog that appears, enter this URL in the "Location" field:
https://dl-ssl.google.com/android/eclipse/

Note: If you have trouble aqcuiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

4. Click OK.

5. Back in the Available Software view, you should see the plugin listed by the URL, with "Developer Tools" nested within it. Select the checkbox next to Developer Tools and click Install...

6. On the subsequent Install window, "Android DDMS" and "Android Development Tools" should both be checked. Click Next.

7. Read and accept the license agreement, then click Finish

8. Restart Eclipse


Eclipse 3.5 (Galileo)

1. Start Eclipse, then select Help > Install New Softare.

2. In the Available Software dialog, click Add....

3. In the Add Site dialog that appears, enter a name for the remote site (e.g., "Android Plugin") in the "Name" field.
In the "Location" field, enter this URL:

https://dl-ssl.google.com/android/eclipse/

Note: If you have trouble aqcuiring the plugin, you can try using "http" in the URL, instead of "https" (https is preferred for security reasons).
Click Ok

4. Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android

5 In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish.

6. Restart Eclipse.


Now modify your Eclipse preferences to point to the Android SDK directory:

1. Select Window > Preferences... to open the Preferences panel (Mac: Eclipse > Preferences).

2. Select Android from the left panel.

3. For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory.

4. Click Apply, then OK.

Done!If you haven't encountered any problems, then you're ready to begin developing Android applications.


What is android

Android is a Linux-based open source platform for mobile cellular handsets. Android was developed by Google and the Open Handset Alliance (OHA), a coalition of hardware, software and telecommunications companies oriented towards advancing mobile telephony standards.

Android platform includes an operating system based upon Linux, a GUI, a Web browser and many other applications considered key to a modern cellular handset. Android allows synchronization to a user's address book, calendar and other personal information management (PIM) programs, though individual software makers will have to customize their offerings.

Android will allow users to browse the Internet more easily, integrate mapping services with local business listings and use many other software features traditionally associated with personal computers rather than cellphones.

Android will run on both of the most widely deployed cellular standards, GSM/HSDPA and CDMA/EV-DO.

 Android will also support:
  • Bluetooth
  • EDGE
  • 3G Communication Protocols, like EV-DO and HSDPA
  • WiFi
  • SMS messaging
  • MMS
  • Video/Still Digital Cameras
  • Touchscreens
  • GPS
  • Compasses
  • Accelerometers
  • Accelerated 3D Graphics
         Android includes software built by many different entities. For instance, the default Android web browser will be based on Webkit, like Apple's Safari. Webkit was originally based on the Konquerer Web browser for Linux. Its music and video playback software was developed by PacketVideo. Applications are written using Java and are run on Dalvik, a virtual machine that runs on top of a Linux kernel.