Question : What does the Android project folder "res/" contain?
1. Java Activity classes
2. Resource files
3. Java source code
4. Libraries
Correct Answer : 2 Explanation: In the /res folder you can have:
anim/ - XML files that define tween animations
color/ - XML files that define a state list of colors.
drawable/ - Bitmap files / Nine-Patches (re-sizable bitmaps) / State lists / Shapes / Animation drawables / Other drawables
layout/ - XML files that define a user interface layout.
menu/ - XML files that define application menus, such as an Options Menu, Context Menu, or Sub Menu.
raw/ - Arbitrary files to save in their raw form.
values/ - XML files that contain simple values, such as strings, integers, and colors.
arrays.xml for resource arrays (typed arrays). colors.xml for color values dimens.xml for dimension values. strings.xml for string values. styles.xml for styles. xml/ - Arbitrary XML files
Question : What does this code do?
Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(android.net.Uri.parse("http://www.androidatc.com")); startActivity(intent);
1. Starts a sub-activity
2. Starts a service
3. Sends results to another activity.
4. Starts an activity using an implicit intent.
Correct Answer : 4 Explanation: Intents are asynchronous messages which allow application components to request functionality from other Android components. Intents allow you to interact with components from the same applications as well as with components contributed by other applications. For example, an activity can start an external activity for taking a picture.
Intents are objects of the android.content.Intent type. Your code can send them to the Android system defining the components you are targeting. For example, via the startActivity() method you can define that the intent should be used to start an activity. An intent can contain data via a Bundle. This data can be used by the receiving component. Different types of intents Android supports explicit and implicit intents. An application can define the target component directly in the intent (explicit intent) or ask the Android system to evaluate registered components based on the intent data (implicit intents). Explicit Intents : Explicit intents explicitly define the component which should be called by the Android system, by using the Java class as identifier. The following shows how to create an explicit intent and send it to the Android system. If the class specified in the intent represents an activity, the Android system starts it.
Intent i = new Intent(this, ActivityTwo.class); i.putExtra("Value1", "This value one for ActivityTwo "); i.putExtra("Value2", "This value two ActivityTwo"); Explicit intents are typically used within on application as the classes in an application are controlled by the application developer. Implicit Intents : Implicit intents specify the action which should be performed and optionally data which provides content for the action. For example, the following tells the Android system to view a webpage. All installed web browsers should be registered to the corresponding intent data via an intent filter.
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.hadoopexam.com")); startActivity(i); If an implicit intent is sent to the Android system, it searches for all components which are registered for the specific action and the fitting data type. If only one component is found, Android starts this component directly. If several components are identified by the Android system, the user will get a selection dialog and can decide which component should be used for the intent.
A component can register itself for actions. Data transfer to the target component An intent contains certain header data, e.g., the desired action, the type, etc. Optionally an intent can also contain additional data based on an instance of the Bundle class which can be retrieved from the intent via the getExtras() method. You can also add data directly to the Bundle via the overloaded putExtra() methods of the Intent objects. Extras are key/value pairs. The key is always of type String. As value you can use the primitive data types (int, float, ...) plus objects of type String, Bundle, Parceable and Serializable.
The receiving component can access this information via the getAction() and getData() methods on the Intent object. This Intent object can be retrieved via the getIntent() method.The component which receives the intent can use the getIntent().getExtras() method call to get the extra data. That is demonstrated in the following code snippet.
Question : Which of the following is a Java call-back method invoked when a view is clicked?
1. Detector
2. OnTapListener
3. OnClickDetector
4. OnClickListener
Correct Answer : 4 Explanation: You may use OnClickListener when you want your compoments to react when users click on them. Most (if not all) of the GUI Android components can be bundled with an OnClickListener, so you can see that its a very important component.