Starting app components
All apps have several components that make up the app. These can be screens, chunks of work, and listeners that wait for an event to happen somewhere.
How to do it...
There are three basic components to any app: the Activity
, the Service
, and the BroadcastReceiver
component:
The most common and most visible component is the
Activity
component:[Activity] public class DestinationActivity : Activity { protected override void OnCreate(Bundle savedState) { base.OnCreate(savedState); } }
To start or display an activity, we simply invoke the
StartActivity()
method, as follows:var intent = new Intent(this, typeof(DestinationActivity)); StartActivity(intent);
The next component that we use is a
Service
, or the chunk of work:[Service] public class DestinationService : IntentService { protected override void OnHandleIntent(Intent intent) { } }
Similar to activities, we start a
Service
using theStartService()
method:var intent = new Intent(this, typeof(DestinationService...