Sunday, 25 January 2015

CONNECTIVITY MANAGER CLASS.


A class that answers queries about the state of network connectivity and notifies applications when the network state change.

The responsibilities of this class are:

1. Monitor network connections (Wi-Fi, GPRS ,UMTC,...)

2.Send broadcast intent when network connectivity changes.

3.Attempt to connect to another network if the current network is lost.

4.Provide an API that allows applications to query state of available networks.


Context.getSystemService(Context.CONNECTIVITY_SERVICE) is called to get an instance of the Connectivity manager class.

PUBLIC METHODS IN THE CONNECTIVITY MANAGER CLASS.
  • NetworkInfo getActiveNetworkInfo()
Returns details about the current active default data network.
  • NetworkInfo[]  getAllNetworkInfo()
Returns connection status information about all network types supported by the device.
  • NetworkInfo  getNetworkInfo(int networkType)
Returns connection status information about a particular network type.
  • int  getNetworkPreference()
Retrieves the current preferred network type.

  •  boolean  isActiveNetworkMetered()
Returns if the currently active data network is metered.

  •  static boolean  isNetworkTypeValid(int networkType)
Tests if a given integer represents a valid network type.

  • boolean  requestRouteToHost(int networkType, int hostAddress)
Ensure that a network route exists to deliver traffic to the specified host via the specified network interface.

  • void  setNetworkPreference(int preference)
Specifies the preferred network type.

  • int  startUsingNetworkFeature(int networkType, String feature)

Tells the underlying networking system that the caller wants to begin using the named feature.

  •  int stopUsingNetworkFeature(int networkType, String feature)
Tells the underlying networking system that the caller is finished using the named feature


CHECKING NETWORK AVAILABILITY SOURCE CODE.




private boolean isNetworkAvailable() {
      ConnectivityManager connectivityManager   = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
     return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}


Wednesday, 15 October 2014

Android programming tutorials.

Labels.


Labels are the simplest widgets in android programming. They are used adjacent to other widgets such as fields.

Dealing with labels in Xml.
This is achieved by adding a TextView element to the layout with an android.text property to set the value of the label itself.

TextView Properties of relevance to labels.

  • android:typeface: Sets the typeface to use for the label (e.gmonospace)
  • android:textStyle: Indicates that the typeface should be made bold(bold), italic (italic), or bold and italic (bold_italic)
  • android:textSize: Specifies the size of the font, in one of several measures: sp(scaled pixels), dip(density-independent pixels), px(raw pixels), in(inches), mm(millimeters). The recommend approach is to use sp, and this is appended to the size, such as 12sp.
  • android:textColor: Sets the color of the label’s text, in RGB hex format (e.g., #FF0000for red

Basic Xml code to demostrate a label.

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="http://mwangisimon.blogspot.com"
/>



Tuesday, 23 September 2014

HOW TO CAPTURE SCREENSHOTS IN WINDOWS 8.0 AND 8.1

This is my first post on this blog.Kindly bear with me incase there shall be any broken parts in my post.However,am going to show you an amazingly easy way to capture screenshots in windows operating system without having to download any applications.

Lets start.
The task is easy.The only two items required to do it are:
  1. English literacy.
  2. Brain.
We are going to make use to two features:
  1. The PrtSc button.
  2. The Paint application
  • The first thing we shall open whatever app or site we want to take screenshot.Done?
 
  • Then press the PrtSc button on your keyboard.
  • Open the "Paint" apllication.
  • Paste (Ctrl+v).
You are done.

Facebook Simon Mwangi