Question : Which configuration file holds the permission to use the internet?
1. Layout file
2. Property file
3. Java source file
4. Manifest file
Correct Answer : 4 Explanation: Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app's code. Among other things, the manifest does the following:
It names the Java package for the application. The package name serves as a unique identifier for the application. It describes the components of the application - the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched. It determines which processes will host application components. It declares which permissions the application must have in order to access protected parts of the API and interact with other applications. It also declares the permissions that others are required to have in order to interact with the application's components. It lists the Instrumentation classes that provide profiling and other information as the application is running. These declarations are present in the manifest only while the application is being developed and tested; they're removed before the application is published. It declares the minimum level of the Android API that the application requires. It lists the libraries that the application must be linked against.
Question : What does the following line of code achieve?
Intent intent = new Intent(FirstActivity.this, SecondActivity.class );
1. Creates an hidden Intent
2. Creates an implicit Intent
3. Create an explicit Intent
4. Create an explicit Intent
Correct Answer : 4 Explanation: Android Explicit intent specifies the component to be invoked from activity. In other words, we can call another activity in android by explicit intent.
We can also pass the information from one activity to another using explicit intent. implicit activity call: In intent filter you create action for you activity, so other app can call your activity via this action as following:
And the Other way to call implicit Intent is below. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); startActivity(intent); Explicit activity call: You make a call that indicate exactly which activity class: Intent intent = new Intent(this, ActivityABC.class); i.putExtra("Value", "This value for ActivityABC"); startActivity(intent); Hope this help you understand more about Explicit and implicit activity call in android.
Question : Which of the following is NOT a valid usage for Intents?
1. Activate and Activity
2. Activate a Service
3. Activate a Broadcast receiver
4. Activate a SQLite DB Connection.
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.