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);


Recent Comments