Monday, August 19, 2013

Sqlite Join - Android, IOS


Sqlite join is used to combine two or more tables in a database. Here is the examples for understanding sqlite join.

sqlite> .schema
CREATE TABLE  EMPLOYEE(EmpId INTEGER, EmpName TEXT);
CREATE TABLE COMPANY(EmpId INTEGER, Position INTEGER,JoiningDate DATE);

Joining Two Tables:


sqlite > select EMPLOYEE.EmpName, COMPANY.Position from EMPLOYEE JOIN COMPANY;

Fused Location Provider android- Google I/O 2013 - Beyond the Blue Dot: New Features in Android




  Android location services are automatically maintains the user current location. Recently google released through google I/O  “Fused Location Providers”. What is the meaning of fused location?
   Taking  Gps, wifi, Mobile network, Sensors  which provides the location and taking best location out of these, By fusing these will give the better location and follows the user position continuously.


 How to implement this api to the android application?
    Android providing google play services library, which will provide the all apis which are required for implementing fused location providers.
  Location providers sends the user current location to the application through LocationClient.
Declare the permissions in the manifest.xml file
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>


Class will implement     implements
              GooglePlayServicesClient.ConnectionCallbacks,
                 GooglePlayServicesClient.OnConnectionFailedListener, LocationListener {

private LocationClient mLocationclient;


int resp = GooglePlayServicesUtil
                           .isGooglePlayServicesAvailable(getActivity());

              if (resp == ConnectionResult.SUCCESS) {
                     mLocationclient = new LocationClient(getActivity(), this, this);
                     mLocationclient.connect();
              } else {
                     GooglePlayServicesUtil.getErrorDialog(resp, getActivity(), 2);
                 }

@Override
       public void onConnected(Bundle arg0) {
              Log.i("location", "onConnected");

              if (mLocationclient != null && mLocationclient.isConnected()) {
                     Location loc = mLocationclient.getLastLocation();
                     if (loc != null) {
                     String locLatitude = "" + loc.getLatitude();
                     String locLongitude = "" + loc.getLongitude();

                                                }
else {
       LocationManager manager = (LocationManager) getActivity()
                                         .getSystemService(Context.LOCATION_SERVICE);

                           if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                                  buildAlertMessageNoGps();
                           }

                     }
              }

       }

       @Override
       public void onDisconnected() {
              Log.i("location", "onDisconnected");

       }

       @Override
       public void onConnectionFailed(ConnectionResult result) {
              Log.i("location", "onConnectionFailed");

       }

       @Override
       public void onLocationChanged(Location location) {
              if (location != null) {
                    
              String locationLatitude = "" + location.getLatitude();
              String locLongitude = "" + location.getLongitude();
              }

       }

      

Sunday, August 11, 2013

Android Internet Connectivity Check Api

   ConnectivityManager connManager = (ConnectivityManager) contex.getSystemService(Context.CONNECTIVITY_SERVICE);

 android.net.NetworkInfo wifi = connManager
                    .getNetworkInfo(ConnectivityManager.TYPE_WIFI);

 android.net.NetworkInfo mobile = connManager
                    .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

            if (wifi.isAvailable()) {
                return true;
            } else if (mobile.isAvailable()) {
                return true;
            } else {
                return false;

            }