For launching an activity, we need to create an explicit intent that defines the activity that we wish to start.…
How to add zoom controls to Android MapView
The following code snippet shows how to add zoom controls to Android MapView. We can achieve this by calling setBuiltInZoomControls(boolean) method. MapView…
How to access accelerometer in Android
The following code snippet will help you with the basic understanding of how to set up the Android accelerometer and…
How to create a background service in Android
To create a background service, first you need to add the service into your manifest file. Then, create a class…
How to Get Device Information in Android
The following code snippet will get the device detailed information in Android. public class DashboardActivity extends Activity { @Override protected…
Linear / Sequential Search Example in Java
Quick Java code snippet to show Linear / Sequential Search. import java.util.Scanner; public class LinearSearchExample { public static void main(String…
How to change upper case string to lower case in Java
Quick Java code snippet to change case of a String in Java. It uses toUpperCase() and toLowerCase() methods present in java.lang.String class to convert…
String length and trim string in java
Code snippet explains the usage of String class length and trim() method. The length() method returns the length of this string. The trim() method…
Insertion sort example in Java
Code snippet to sort array using insertion sort algorithm in java. public class InsertionSortExample { static int step = 1;…