This example demonstrates how do I monitor Network connections status in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml Step 3 − Add the following code to src/MainActivity.javaimport android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; public class MainActivity extends AppCompatActivity { ImageView ivConStatus; TextView tvconStatus; Button btnCheckNetwork; @Override protected void onCreate(Bundle savedInstanceState) ... Read More
This example demonstrates how do I develop a speech recognizer in android without Google API.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; import android.speech.RecognitionListener; import android.speech.RecognizerIntent; import android.speech.SpeechRecognizer; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.CompoundButton; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import ... Read More
This example demonstrates how do I detect phone calls in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport android.Manifest; import android.content.pm.PackageManager; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED){ ... Read More
Huffman coding is lossless data compression algorithm. In this algorithm a variable-length code is assigned to input different characters. The code length is related with how frequently characters are used. Most frequent characters have smallest codes, and longer codes for least frequent characters.There are mainly two parts. First one to create Huffman tree, and another one to traverse the tree to find codes.For an example, consider some strings “YYYZXXYYX”, the frequency of character Y is larger than X and the character Z has least frequency. So the length of code for Y is smaller than X, and code for X ... Read More
Power line communications (PLC) allows data communications over conductors that are simultaneously used for transmission of electrical power.PLCs work by adding a modulated carrier signal, formed by superimposing data signal over low frequency power signal. Electrical signals transmit at 50 – 60 Hz, while the data signals transmit in the order of MHz.PLCs are also known as power line carrier, power line digital subscriber line (PDSL), or power line networking (PLN).Types of PLC:Narrowband PLC: They work at lower frequencies of 3-500KHz. Their data rates are low but have high range of several kilometres. They are used in the Smart Grid.Broadband ... Read More
Data rate refers to the speed of data transfer through a channel. It is generally computed in bits per second (bps). Higher data rates are expressed as Kbps ("Kilo" bits per second, i.e.1000 bps), Mbps ("Mega" bits per second, i.e.1000 Kbps), Gbps ("Giga" bits per second, i.e. 1000 Mbps) and Tbps ("Tera" bits per second, i.e. 1000 Gbps).One of the main objectives of data communications is to increase the data rate. There are three factors that determine the data rate of a channel:Bandwidth of the channelNumber of levels of signals that are usedNoise present in the channelData rate can be ... Read More
Fourier analysis is a method of representing general functions by approximate sum of simple trigonometric functions. The method is named after mathematician Jean Baptiste Joseph Fourier who formulated and proved the Fourier series. Fourier analysis is used in electronics, communications and acoustics.The Fourier series decomposes a periodic function as a sum of sine and cosine components as expressed below:where, g(t) is the periodic functionT is the time periodf is the fundamental frequency expressed as 1/Tan is the sine amplitude of the nth harmonicbn is the cosine amplitude of the nth harmonicc is a constantThe values of an, bn and c ... Read More
The Breadth First Search (BFS) traversal is an algorithm, which is used to visit all of the nodes of a given graph. In this traversal algorithm one node is selected and then all of the adjacent nodes are visited one by one. After completing all of the adjacent vertices, it moves further to check another vertices and checks its adjacent vertices again.To implement this algorithm, we need to use the Queue data structure. All the adjacent vertices are added into the queue, when all adjacent vertices are completed, one item is removed from the queue and start traversing through that ... Read More
The Depth First Search (DFS) is a graph traversal algorithm. In this algorithm one starting vertex is given, and when an adjacent vertex is found, it moves to that adjacent vertex first and try to traverse in the same manner.It moves through the whole depth, as much as it can go, after that it backtracks to reach previous vertices to find new path.To implement DFS in iterative way, we need to use the stack data structure. If we want to do it recursively, external stacks are not needed, it can be done internal stacks for the recursion calls.Input: The Adjacency ... Read More
The graph is a non-linear data structures. This represents data using nodes, and their relations using edges. A graph G has two sections. The vertices, and edges. Vertices are represented using set V, and Edges are represented as set E. So the graph notation is G(V, E). Let us see one example to get the idea.In this graph, there are five vertices and five edges. The edges are directed. As an example, if we choose the edge connecting vertices B and D, the source vertex is B and destination is D. So we can move B to D but not ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP