Showing posts with label connection. Show all posts
Showing posts with label connection. Show all posts

Thursday, 24 January 2013

Check Internet Connection in Android


       public boolean isOnline() {
              ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
              NetworkInfo netInfo = cm.getActiveNetworkInfo();

              if (netInfo != null && netInfo.isConnectedOrConnecting()
                           && cm.getActiveNetworkInfo().isAvailable()
                           && cm.getActiveNetworkInfo().isConnected()) {
                     return true;
              }
              return false;
       }


there another method you want to use 


       public static boolean haveNetworkConnection(final Context context) {
              boolean haveConnectedWifi = false;
              boolean haveConnectedMobile = false;

              final ConnectivityManager cm = (ConnectivityManager) context
                           .getSystemService(Context.CONNECTIVITY_SERVICE);
              if (cm != null) {
                     final NetworkInfo[] netInfo = cm.getAllNetworkInfo();
                     for (final NetworkInfo netInfoCheck : netInfo) {
                           if (netInfoCheck.getTypeName().equalsIgnoreCase("WIFI")) {
                                  if (netInfoCheck.isConnected()) {
                                         haveConnectedWifi = true;
                                  }
                           }
                           if (netInfoCheck.getTypeName().equalsIgnoreCase("MOBILE")) {
                                  if (netInfoCheck.isConnected()) {
                                         haveConnectedMobile = true;
                                  }
                           }
                     }
              }

              return haveConnectedWifi || haveConnectedMobile;
       }


=============================================================


         if (haveNetworkConnection(Activity.this))
           {
                //Conneced
           }
       else
           {
                //No Connected
           }





Note:- you also give User Permission
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Friday, 18 January 2013

How to connect android device in Linux (Ubantu)

Connect Android Device for Development in Linux (Ubuntu)

Connecting android device in ubuntu (Linux) guide.
First of all you have to login with root user. If there is no root login then enable root login using following steps:
 Enable the root account in Ubuntu ,
Please follow below steps
1 . To get started, Open terminal - press Ctrl – Alt – T 
on your keyboard to open Terminal.  
2. When it opens, run the commands below to create a new root password.

sudo passwd root

It asks for new password for root login.

3.  copy and paste the commands below to enable manual or other login.

sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'

Restart your computer and choose to login as root.

Log in as root and create this file: /etc/udev/rules.d/51-android.rules.

Use this format to add each vendor to the file:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

List of vendor Ids :
http://developer.android.com/tools/device.html#VendorIds

In this example, the vendor ID is for HTC, vendor id of HTC is “0bb4”. The MODE assignment specifies read/write permissions, and GROUP defines which Unix group owns the device node.

You can add multiple device vendor id with creating new line for each venor
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

After , Save the file and run the following command in terminal

Now execute:
chmod a+r /etc/udev/rules.d/51-android.rules

Restart the eclipse and enjoy the usb debugging in android with ubuntu.

Our new android application for EGreeting.Have a look to it.
 The Greetings Android Application 


NovaRadix Android Application Development Team
NovaRadix Technology
WWW.NOVARADIX.COM

Call web services easily

get source code from here, Download