Saturday 29 March 2014

Creating the first android application;

Before that visit blog to install the software to work with andriod application ;


Creating the first android application;


1.       Open up the eclipse application;Give the work space name to your application.(it will become the application name)

3.       It will open the window like below then click on the button of New Android Application

4.       Once you click on the button it will ask for application name, project name and the package name which will appear  on the screen.


5.       Once you done click on next ; on below window you can provide the certain configuration. For time being click on next;

6.       Once you click on Next you will get the below window it ask for launcher Icon and background color; here also click on next;



7.       You will get the screen like below;





8.       You will get the Screen like below, It will create the lots of file but will give the details in later article. The page is opened as MainActivity.java




9.  Run the applications By clicking the Run on menu.

   
10. You will get the selection screen like below;


11. It will open the emulator like below; (if not then you need to create the emulator which you will learn on another blog)

.
12.   It will take around 4-5 as you are running the application first time to get open your application. Now you will see the screen like below;


You will get the below screen where you can see your running application.


Congratulations,You have created your first Android application

Monday 24 March 2014

Change IP on an Android Emulator

You need to  follow the below steps to change the IP of Emulator;

1: Start Android emulator.

2:Click on  "Settings" icon.

4:Click on "More" and select "Advanced."

5:Select "Use Static IP" button.

6 :Select  the "IP Address."
Type in the new IP address you wish you use using four dot notation (X.X.X.X). Click "OK" to save the settings

how to find ip address in android eclipse

Get the IP address on your android mobile application.

You first need to import the below
import org.apache.http.conn.util.InetAddressUtils;

You need to place the below code to get the IP address;

public static String getIPAddress(boolean useIPv4) {
        try {
            List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
            for (NetworkInterface intf : interfaces) {
                List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
                for (InetAddress addr : addrs) {
                    if (!addr.isLoopbackAddress()) {
                        String sAddr = addr.getHostAddress().toUpperCase();
                        boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
                        if (useIPv4) {
                            if (isIPv4)
                                return sAddr;
                        } else {
                            if (!isIPv4) {
                                int delim = sAddr.indexOf('%'); // drop ip6 port suffix
                                return delim<0 ? sAddr : sAddr.substring(0, delim);
                            }
                        }
                    }
                }
            }
        } catch (Exception ex) { } // for now eat exceptions
        return "";

    }


You need to give the Permission in android Manifest as below;

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

Sunday 23 March 2014

Building Android Application

To work with ethe android application you should have folowing below software then you can proceed with it.Software required to work with andriod application.

It will build the envinomet for you. Please install the below software;


  1. Download the Android SDK.
  2. Install the ADT plugin for Eclipse (if you’ll use the Eclipse IDE).
  3. Download the latest SDK tools and platforms using the SDK Manager.

You can install the above software from here;
With that single link you will get the following software; it is full package of software;


  1. Eclipse + ADT plugin
  2. Android Platform-tools
  3. Android SDK Tools
  4. The latest Android platform
  5. The latest Android system image for the emulator

How to change the display name of apk on installed system.

You can change the installed application name according to need and you can check it by task manager that whatever the name given by you for your application is correct or not.
You need to follow below steps and you can give the name to your installed app. It is behave like the label of application also.
1.       Click [Your project name] in Eclipse Package Explorer,
2.       Select res -> values -> strings.xml



3.       Once you click on the string it will open the config window like below and there you need to select the app_name(double click on)


changing package name in eclipse

Some time it happens that we need to change the name of package. Eclipse give you the provision to change the name of application package very easily.

You just need to follow the below steps to do this.
1- Right click on project. & choose Android Tools.


2- Choose Rename application package
                                                


3- Type new application name then press OK.

Saturday 22 March 2014

toggle buttons in android


It allows the user to change the states by one button and user can identify it through the button text.
Here is the example to work with the toggle button. You need to place the toggle button control in the XML screen it will look like as;

XML code for that Toggle button control  will be look alike;
<ToggleButton 

    android:id="@+id/btnToggle"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:textOn="On"

    android:textOff="Off"

    android:onClick="onToggleClicked"/>
Event to handle in code side  there it will fire the onToggleClicked event;
public void onToggleClicked(View view) {

   

    boolean on = ((ToggleButton) view).isChecked();

    

    if (on) {

        // Enable Yes

    } else {

        // Disable NO

    }

}
Finally it will look like;