Creating Android Application Components
An Android application may contain the following components:
AIDL: an Android Interface Definition Language (AIDL) interface used for interprocess communication.
Activity: implements a window where you place your UI to interact with the user.
Android Auto: lets you extend your application for use in vehicles. You can add either Media Service or Messaging Service activity.
Folder: creates a source root based on the activity you have selected for this component.
Fragment: represents a behavior or a part of user interface in an activity.
Google: lets you create an activity for Google maps and AdMob Ads activities.
Application: an Android package, i.e. an .apk archive that contains the contents of an Android app and the installer.
Service: represents an application's desire either to perform an operation without interacting with the user, or to supply functionality for other applications.
- Other: lets you add the following components to your application:
UI Component: lets you add custom views to you application.
Wear: lets you extend your application for use in Android wear.
Widget: lets you add different types of widgets for your application.
XML: lets you add different types .xml files for Android layouts and values.
All Android application components are created in the same way. When you create a new component, a class that implements this component is generated and the component is automatically declared in the AndroidManifest.xml file.
On this page:
- Creating an Android component
- Navigating between an activity or a fragment and its related layout definition file
- Navigating from a component to its declaration in the AndroidManifest.xml file
Creating an Android component
In the Project view, right-click the destination package where the application classes are stored and from the context menu, select New | 'component name' and the specific service, file or an activity.
In the dialog box that opens, specify the necessary information and click Finish.
Note that when you create an activity, a service or a broadcast receiver, they are automatically registered in the androidmanifest.xml file.
Navigating between an activity or a fragment and its related layout definition file
You can jump from the source code of an activity or a fragment to the layout definition file which represents its content view and vice versa, from the layout definition to the source code.
To jump from a component to its related layout definition, open the source code of the component, and do one of the following:
Click the icon in the gutter area and choose the layout definition file in the Go To Related Symbol list.
On the main menu, choose.
To jump from a layout definition to the source code of the corresponding component, open the layout definition file in the text mode and do one of the following:
Click the icon in the gutter area.
On the main menu, choose.
Navigating from a component to its declaration in the AndroidManifest.xml file
As soon as a component is created, it is immediately declared in the AndroidManifest.xml file. For components of the activity, fragment, service, and broadcast receiver type, you can jump to this declaration right from the component source code.
Open the source code of the component, and click the icon in the gutter area.
If the component also has a related layout definition file, choose AndroidManifest.xml in the Go To Related Symbol list.