Jun 30

Wifi

The WifiManager can be used to enable and disable wifi.

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(enabled);

GPS Location
we can use LocationManager to start up the GPS and get location updates.

LocationManager locator = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener mLocationListener = new LocationListener() {
  public void onLocationChanged(Location location) {
    if (location != null) {
      location.getAltitude();
      location.getLatitude();
      location.getLongitude();
      location.getTime();
      location.getAccuracy();
      location.getSpeed();
      location.getProvider();
    }
  }

  public void onProviderDisabled(String provider) {
    // ...
  }

  public void onProviderEnabled(String provider) {
    // ...
  }

  public void onStatusChanged(String provider, int status, Bundle extras) {
    // ...
  }
};

// You need to specify a Criteria for picking the location data source.
// The criteria can include power requirements.
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);  // Faster, no GPS fix.
criteria.setAccuracy(Criteria.ACCURACY_FINE);  // More accurate, GPS fix.
// You can specify the time and distance between location updates.
// Both are useful for reducing power requirements.
mLocationManager.requestLocationUpdates(mLocationManager.getBestProvider(criteria, true),
    MIN_LOCATION_UPDATE_TIME, MIN_LOCATION_UPDATE_DISTANCE, mLocationListener,
    getMainLooper());

we can also get the phone’s last known location using the LocationManager. This is faster than setting up a LocationListener and waiting for a fix.

// Start with fine location.
Location l = locator.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (l == null) {
  // Fall back to coarse location.
  l = locator.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}

SMS
we can send SMS by using SmsManager.

SmsManager sm = SmsManager.getDefault();
String destination = "+919822390027";
String text = "Hello, jony!";
sm.sendTextMessage(destination, null, text, null, null);

Vibrate
we can vibrate the phone for a specified duration

(Vibrator) getSystemService(Context.VIBRATOR_SERVICE).vibrate(milliseconds);
Tagged with:
Apr 21

My MacBook

Like first love, you don’t get anything like your first laptop.

I got my first laptop – a MacBook. I am so excited. Honestly, I didn’t initially intend on getting a MacBook because its too costly. but later I realize that spending that much of money is really worth.

It’s quite a beautiful piece of equipment, but I’m not just looking for a beautiful notebook, one factor that I value most from a notebook is durability. Because I plan to use the machine as my main computer where I do my programming with Java, Android and other activity.

Usually beauty and durability does not came along together but apple made it. apple combine such characters into the macbook and with the OS X easy to use and stability (good performance too).

I love my MacBook! The multi-touch trackpad and battery life are AMAZING!
here are some Pros and Cons

Pros:
-Multi-Touch Trackpad
-Magnetic Power Connector
-13.3 inch Gorgeous Screen
-Easy to Fast-type Keyboard
-7 Hour Battery Life
-2.26GHz Processor! (Super fast!)
-It is just amazing

Cons:
-No SD card slot (not a big deal AT ALL)

Apr 14

No Electricity

Bangalore is supposed to be the IT capital of India. They even call it the Silicon Valley of India. So much for that! but Karnataka Electricity Board or the BESCOM are not able to handle eccentricity problems.

Frequent power cuts are very common here. There is no scheduled power cut and power comes and goes all the time. Presently We are having a minimum four-hour cut which sometimes goes on to six hours. In summer the power condition is almost like an village, there is no power at all, sometimes the whole day… sometimes the whole night… The most weird part is when I call up the electric board office in my area, they don’t even pick up the call and when they do, ( I am very lucky that time because they pick up phone) they gave very funny answers. or speak very rudely or telling me that they can’t help.

One more thing that surprise me, The Earth Hour campaign. Karnataka government spent lot of money to advertise this event. There are lot of hoardings like “Please switch off your lights for one hour” but they don’t know, everyday we celebrate earth hour. I think in India everybody celebrates earth hour, there is no need to celebrate this event in specific day.

I think government should not waste money in event like this they should invest money in power generation and good distribution structure.

Tagged with:
Apr 09

Google has confirmed in an update that the number of Android applications has almost doubled in only last three months. By mid-December, there have been 16,000 applications, now the number has jumped to over 30,000. The statistics refer to both free and paid apps. I think its may be due to the accelerated Android phone sales. which also increased the interest in apps development.

The number of android apps are increasing day by day. In march Android Market shot up by 68 percent, new data from AndroLib claimed. In February 5,532 new applications added to the store, the app count grew by a much larger 9,320 new applications in last month.

Android Statistics

Mar 31

The application I’m currently working requires that the user has the GPS active on phone. otherwise application is useless. The application needs the Geodata to function. This brought up the issue of, how do we know if the user actually has the GPS enabled on the phone? If they don’t, the application will still work, but all values are zero. to avoid this we need to check GPS status.

This can be done by using locationManager. it has isProviderEnabled() method by using that we can check GPS status.

Here is code snippet.

protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);
     LocationManager locManager = (LocationManager) getSystemService(LOCATION_SERVICE);

     if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
          createGpsDisabledAlert();
     }
}

private void createGpsDisabledAlert(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Your GPS is disabled! Would you like to enable it?")
     .setCancelable(false)
     .setPositiveButton("Enable GPS",
          new DialogInterface.OnClickListener(){
          public void onClick(DialogInterface dialog, int id){
               showGpsOptions();
          }
     });
     .setNegativeButton("Do nothing",
          new DialogInterface.OnClickListener(){
          public void onClick(DialogInterface dialog, int id){
               dialog.cancel();
          }
     });
AlertDialog alert = builder.create();
alert.show();
}

private void showGpsOptions(){
		Intent gpsOptionsIntent = new Intent(
				android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
		startActivity(gpsOptionsIntent);
}

And thats it! When the user starts the activity, if the GPS is off, the dialog will pop up asking them what they want to do. If the GPS is already on, nothing will happen.

Tagged with:
Mar 31

Currently I am working on GPS related project. and every day I am exploring new things. Now I realize that GPS is very interesting technology and we can make lot of useful things by using GPS.

The new thing today I learned is, finding distance between two points. Previously I was thinking that, it may be difficult but, thankfully there is a much simpler way to figure out distances between two points on a map: the distanceTo() method in the Location class. Using this handy little method, we can quickly find out the distance between two locations:

double distance;

Location locationA = new Location("point A");

locationA.setLatitude(latA);
locationA.setLongitude(lngA);

Location locationB = new Location("point B");

locationB.setLatitude(latB);
LocationB.setLongitude(lngB);

distance = locationA.distanceTo(locationB);

One thing to note is that the distanceTo() method returns the distance in meters, so you will need to do the appropriate calculations if you want your distances in other units.

Tagged with:
preload preload preload