Android

How to create Android Menus Tutorial

android

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="http://schemas.android.com/apk/res/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

android

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

android

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

android

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

android

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 Android.mk file and ... Read More »

What is Android NDK?

android

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

android

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

android

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

android

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 »

Android Widget – Spinner

android

Android spinners are not nothing but the dropdownlist seen in other programming languages. It provides a easy way to select value from list. Clicking spinner will display a dropdownlist with the available values. In this tutorial, we show you how to do the following tasks : 1.Render a Spinner in XML, and load the selection items via XML file also. ... Read More »