Author Archives: jkoder

CORS Filter for J2EE Application


CORS (Cross-origin resource sharing) helps in making Javascript based AJAX request from one domain to another, requesting domain is different from the domain where the request is made. This type of request is by default forbidden at the browser level and if this type of requet is made without proper settings, they will result in some origin security policy error. ... Read More »

How to create Android Menus Tutorial


Options Menu Options menu is created when the user presses the menu button while the Activity is active. Step 1 – Creating the menu XML <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="">    <item android:id="@+id/new_game"          android:icon="@drawable/ic_new_game"          android:title="@string/new_game" />    <item android:id="@+id/quit"          android:icon="@drawable/ic_quit"          android:title="@string/quit" /> </menu> Step 2 – Showing the menu (implemented in Activity class) @Override public boolean onCreateOptionsMenu(Menu menu) {    MenuInflater inflater = ... Read More »

Android Questions & Answers for Experienced


Q. What is assert? Where will you use it? – Assertion is a statement in java. It can be used to test your assumptions about the program. While executing assertion, it is believed to be true. If it fails, JVM will throw an error named AssertionError. It is mainly used for testing purpose. for Example assert value>=18:” Not valid”; Q. ... Read More »

Essential Android Interview Question & Answer


Q.1 There are four Java classes related to the use of sensors on the Android platform. List them and explain the purpose of each. – The four Java classes related to the use of sensors on the Android platform are: Sensor: Provides methods to identify which capabilities are available for a specific sensor. SensorManager: Provides methods for registering sensor event ... Read More »

Android Interview Questions & Answer


Q.1 Explain in brief about the important file and folder when you create new android application. When you create android application the following folders are created in the package explorer in eclipse which are as follows: src: Contains the .java source files for your project. You write the code for your application in this file. This file is available under ... Read More »

Using the Android NDK


Create a regular Android project Add a new folder to your project – <project>/JNI Write a native (C/C++) code and place the files under <project>/JNI. You should follow the JNI rules when writing your native code. Example: #include <string.h> #include <jni.h>   jstring Java_com_mypackage_helloworld_HelloWorld_getNativeString( JNIEnv* env, jobject obj ) {     return (*env)->NewStringUTF(env, "Hello World"); } Create a file and ... Read More »

What is Android NDK?


What is Android NDK? NDK (Native Development Kit) is a set of tools that enables you to easily include native code written in C or C++ in your Android applications. The NDK uses the JNI mechanism to call functions from Java to C and C++. The NDK was introduced with Android version 1.5. In version 2.3 some major improvements were ... Read More »

Android Chronometer


Chronometer Class that implements a simple timer You can give it a start time in the elapsedRealtime() timebase, and it counts up from that, or if you don’t give it a base time, it will use the time at which you call start(). The timer can also count downward towards the base time by setting setCountDown(boolean) to true. By default ... Read More »

Android – WebView


WebView is a view that display web pages inside your application. You can also specify HTML string and can show it inside your application using WebView. WebView makes turns your application to a web application. In order to add WebView to your application, you have to add element to your xml layout file. Its syntax is as follows – <webview ... Read More »

Android AnalogClock and DigitalClock


In Android, the AnalogClock is a two-handed clock, one for hour indicator and the other for minute indicator. The DigitalClock is look like your normal digital watch on hand, which display hours, minutes and seconds in digital format. Both AnalogClock and DigitalClock are UNABLE to modify the time, if you want to change the time, use “TimePicker” instead. Open “your.xml” ... Read More »